#include <bits/stdc++.h> using namespace std; #define e1 first #define e2 second #define pb push_back #define mp make_pair #define boost ios_base::sync_with_stdio(false) #define eb emplace_back #define OUT(x) {cout << x; exit(0); } typedef long long int ll; typedef unsigned long long ull; typedef pair <int, int> PII; typedef unsigned int ui; const int mod = 1e9+7; const int inf = 1e9+9; const ll MOD = 1e9+696969; const ll INF = 1e18+3; int wyn = -inf, n, sum = 0; int t[1000100]; int main() { scanf("%d", &n); for (int i=1; i<=n; ++i) scanf("%d", &t[i]), sum += t[i]; if (n == 1 && (sum & 1)) OUT("NIESTETY"); if (!(sum & 1)) wyn = max(wyn, sum); for (int i=1; i<=n; ++i) { int tmp = sum; tmp -= t[i]; if (!(tmp & 1)) wyn = max(wyn, tmp); } if (wyn != -inf) printf("%d", wyn); else printf("NIESTETY"); }
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 | #include <bits/stdc++.h> using namespace std; #define e1 first #define e2 second #define pb push_back #define mp make_pair #define boost ios_base::sync_with_stdio(false) #define eb emplace_back #define OUT(x) {cout << x; exit(0); } typedef long long int ll; typedef unsigned long long ull; typedef pair <int, int> PII; typedef unsigned int ui; const int mod = 1e9+7; const int inf = 1e9+9; const ll MOD = 1e9+696969; const ll INF = 1e18+3; int wyn = -inf, n, sum = 0; int t[1000100]; int main() { scanf("%d", &n); for (int i=1; i<=n; ++i) scanf("%d", &t[i]), sum += t[i]; if (n == 1 && (sum & 1)) OUT("NIESTETY"); if (!(sum & 1)) wyn = max(wyn, sum); for (int i=1; i<=n; ++i) { int tmp = sum; tmp -= t[i]; if (!(tmp & 1)) wyn = max(wyn, tmp); } if (wyn != -inf) printf("%d", wyn); else printf("NIESTETY"); } |