#include <vector> #include <iostream> #include <algorithm> using namespace std; typedef unsigned long long int ull; int main() { ull n; scanf("%llu", &n); ull sum = 0; int oddCount = 0; int minOdd = 100000; for (int i = 0; i < n; ++i) { int tmp; scanf("%d", &tmp); sum += tmp; if (tmp & 1) { minOdd = min(tmp, minOdd); oddCount++; } } if (oddCount&1) sum -= minOdd; if (sum == 0) cout << "NIESTETY" << endl; else cout << sum << endl; 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 30 31 32 33 | #include <vector> #include <iostream> #include <algorithm> using namespace std; typedef unsigned long long int ull; int main() { ull n; scanf("%llu", &n); ull sum = 0; int oddCount = 0; int minOdd = 100000; for (int i = 0; i < n; ++i) { int tmp; scanf("%d", &tmp); sum += tmp; if (tmp & 1) { minOdd = min(tmp, minOdd); oddCount++; } } if (oddCount&1) sum -= minOdd; if (sum == 0) cout << "NIESTETY" << endl; else cout << sum << endl; return 0; } |