#include <iostream> #include <algorithm> #include <cstdio> using namespace std; int main(int argc, char* argv[]) { int n, a, minp = 0, minnp = 0; int res = 0; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &a); res += a; if (a & 1) { minnp = a < minnp || minnp == 0 ? a : minnp; } else { minp = a < minp || minp == 0 ? a : minp; } } if (res & 1) res -= minnp; if (!res) printf("NIESTETY"); else printf("%d", res); printf("\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 | #include <iostream> #include <algorithm> #include <cstdio> using namespace std; int main(int argc, char* argv[]) { int n, a, minp = 0, minnp = 0; int res = 0; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &a); res += a; if (a & 1) { minnp = a < minnp || minnp == 0 ? a : minnp; } else { minp = a < minp || minp == 0 ? a : minp; } } if (res & 1) res -= minnp; if (!res) printf("NIESTETY"); else printf("%d", res); printf("\n"); return 0; } |