#include <stdio.h> #define N 1000007 #define M 1007 int mon[N]; int solution(int n) { int m = M, i, s = 0; for (i = 0; i < n; ++i) { s += mon[i]; if (m > mon[i] && mon[i] % 2) m = mon[i]; } if (m == M || s % 2 == 0) return s; return s - m; } int main() { int n, i, s; scanf("%d", &n); for (i = 0; i < n; ++i) scanf("%d", &mon[i]); s = solution(n); if (s > 0) printf("%d\n", s); else printf("NIESTETY\n"); 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 | #include <stdio.h> #define N 1000007 #define M 1007 int mon[N]; int solution(int n) { int m = M, i, s = 0; for (i = 0; i < n; ++i) { s += mon[i]; if (m > mon[i] && mon[i] % 2) m = mon[i]; } if (m == M || s % 2 == 0) return s; return s - m; } int main() { int n, i, s; scanf("%d", &n); for (i = 0; i < n; ++i) scanf("%d", &mon[i]); s = solution(n); if (s > 0) printf("%d\n", s); else printf("NIESTETY\n"); return 0; } |