#include <cstdio> #include <cstdlib> using namespace std; #define MAXN 1000001 #define MAXV 1001 int tab[MAXN]; main() { int n; scanf("%d", &n); int total = 0; for(int i = 0;i<n; i++) { scanf("%d", tab + i); total += tab[i]; } int res = 0; if(total%2 == 0) { res = total; } else { int lowest = MAXV; for(int i = 0; i<n; i++) { if(tab[i]%2 == 1 && lowest > tab[i]) { lowest = tab[i]; } } res = total - lowest; } if(res > 0) { printf("%d\n", res); } else { printf("NIESTETY\n"); } }
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 <cstdio> #include <cstdlib> using namespace std; #define MAXN 1000001 #define MAXV 1001 int tab[MAXN]; main() { int n; scanf("%d", &n); int total = 0; for(int i = 0;i<n; i++) { scanf("%d", tab + i); total += tab[i]; } int res = 0; if(total%2 == 0) { res = total; } else { int lowest = MAXV; for(int i = 0; i<n; i++) { if(tab[i]%2 == 1 && lowest > tab[i]) { lowest = tab[i]; } } res = total - lowest; } if(res > 0) { printf("%d\n", res); } else { printf("NIESTETY\n"); } } |