// Grzegorz Bukowiec // PA 2015 - Zadanie 1B - Kieszonkowe #include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(0); int n, a, minOdd = 1001, sum = 0; cin >> n; for (int i = 0; i < n; ++i) { cin >> a; sum += a; if (a % 2 && minOdd > a) { minOdd = a; } } if (sum % 2 == 0) { cout << sum; } else if (n > 1) { cout << sum - minOdd; } else { cout << "NIESTETY"; } return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | // Grzegorz Bukowiec // PA 2015 - Zadanie 1B - Kieszonkowe #include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(0); int n, a, minOdd = 1001, sum = 0; cin >> n; for (int i = 0; i < n; ++i) { cin >> a; sum += a; if (a % 2 && minOdd > a) { minOdd = a; } } if (sum % 2 == 0) { cout << sum; } else if (n > 1) { cout << sum - minOdd; } else { cout << "NIESTETY"; } return 0; } |