#include <cstdio> #include <algorithm> const int INF = 2000; int main() { int notesCnt, sum = 0, smallestOdd = INF; scanf("%d", ¬esCnt); for(int i = 0; i < notesCnt; ++i) { int n; scanf("%d", &n); sum += n; if (n % 2 != 0) smallestOdd = std::min(smallestOdd, n); } if(sum % 2 == 0) printf("%d", sum); else if(smallestOdd != INF and sum - smallestOdd > 0) printf("%d", sum - smallestOdd); else printf("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 | #include <cstdio> #include <algorithm> const int INF = 2000; int main() { int notesCnt, sum = 0, smallestOdd = INF; scanf("%d", ¬esCnt); for(int i = 0; i < notesCnt; ++i) { int n; scanf("%d", &n); sum += n; if (n % 2 != 0) smallestOdd = std::min(smallestOdd, n); } if(sum % 2 == 0) printf("%d", sum); else if(smallestOdd != INF and sum - smallestOdd > 0) printf("%d", sum - smallestOdd); else printf("NIESTETY"); return 0; } |