#include <iostream> using namespace std; unsigned S=0; unsigned il[1000]; unsigned n; short a; void prog() { for (unsigned i = 0; i < 1000; i++) { il[i] = 0; } cin >> n; for (unsigned i = 0; i < n; i++) { cin >> a; il[a - 1]++; S += a; } if (S % 2 == 0) { cout << S; return; } else { unsigned i = 0; for (; i < 1000; i += 2) { if (il[i]>0) { S -= i + 1; if (S > 0)cout << S; else cout << "NIESTETY"; return; } } cout << "NIESTETY"; } } int main() { prog(); 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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | #include <iostream> using namespace std; unsigned S=0; unsigned il[1000]; unsigned n; short a; void prog() { for (unsigned i = 0; i < 1000; i++) { il[i] = 0; } cin >> n; for (unsigned i = 0; i < n; i++) { cin >> a; il[a - 1]++; S += a; } if (S % 2 == 0) { cout << S; return; } else { unsigned i = 0; for (; i < 1000; i += 2) { if (il[i]>0) { S -= i + 1; if (S > 0)cout << S; else cout << "NIESTETY"; return; } } cout << "NIESTETY"; } } int main() { prog(); return 0; } |