#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MX = 1e6 + 5;
LL n, a[MX], suma;
int main() {
scanf("%d", &n);
for (int i = 0; i < n; ++ i) {
scanf("%lld", &a[i]);
suma += a[i];
}
if (suma % 2 == 0)
printf("%lld\n", suma);
else {
LL res = 0LL;
for (int i = 0; i < n; ++ i)
if (a[i] % 2 == 1LL)
res = max(res, suma - a[i]);
if (!res)
puts("NIESTETY");
else
printf("%lld\n", res);
}
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 <bits/stdc++.h> using namespace std; typedef long long LL; const int MX = 1e6 + 5; LL n, a[MX], suma; int main() { scanf("%d", &n); for (int i = 0; i < n; ++ i) { scanf("%lld", &a[i]); suma += a[i]; } if (suma % 2 == 0) printf("%lld\n", suma); else { LL res = 0LL; for (int i = 0; i < n; ++ i) if (a[i] % 2 == 1LL) res = max(res, suma - a[i]); if (!res) puts("NIESTETY"); else printf("%lld\n", res); } return 0; } |
English