#include <cstdio> #include <algorithm> using namespace std; const int MAXN = 1e6+10; int n, a[MAXN], total, min_odd = MAXN; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); total += a[i]; if (a[i]%2 == 1) min_odd = min(min_odd, a[i]); } if (n == 1 && a[1]%2 == 1) { printf("NIESTETY\n"); return 0; } int kochamjulie = total - min_odd * (total%2); printf("%d\n", kochamjulie); 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 | #include <cstdio> #include <algorithm> using namespace std; const int MAXN = 1e6+10; int n, a[MAXN], total, min_odd = MAXN; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); total += a[i]; if (a[i]%2 == 1) min_odd = min(min_odd, a[i]); } if (n == 1 && a[1]%2 == 1) { printf("NIESTETY\n"); return 0; } int kochamjulie = total - min_odd * (total%2); printf("%d\n", kochamjulie); return 0; } |