#include <bits/stdc++.h> using namespace std; #define PB push_back #define FORE(i, t) for(typeof(t.begin())i=t.begin();i!=t.end();++i) #define SZ(x) int((x).size()) #define REP(i, n) for(int i=0,_=(n);i<_;++i) #define FOR(i, a, b) for(int i=(a),_=(b);i<=_;++i) #define FORD(i, a, b) for(int i=(a),_=(b);i>=_;--i) typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; const int INF = 1e9 + 9; int get_max_kieszonkowe(int sum, int min_odd) { if (sum % 2 == 0) { return sum; } if (min_odd != INF) { return sum - min_odd; } return 0; } void inline one() { int n; scanf("%d", &n); int min_odd = INF; int sum = 0; REP (i, n) { int a; scanf("%d", &a); sum += a; if (a % 2 == 1) { min_odd = min(min_odd, a); } } int result = get_max_kieszonkowe(sum, min_odd); if (result > 0) { printf("%d\n", result); } else { puts("NIESTETY"); } } int main() { //int z; scanf("%d", &z); while(z--) one(); }
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | #include <bits/stdc++.h> using namespace std; #define PB push_back #define FORE(i, t) for(typeof(t.begin())i=t.begin();i!=t.end();++i) #define SZ(x) int((x).size()) #define REP(i, n) for(int i=0,_=(n);i<_;++i) #define FOR(i, a, b) for(int i=(a),_=(b);i<=_;++i) #define FORD(i, a, b) for(int i=(a),_=(b);i>=_;--i) typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; const int INF = 1e9 + 9; int get_max_kieszonkowe(int sum, int min_odd) { if (sum % 2 == 0) { return sum; } if (min_odd != INF) { return sum - min_odd; } return 0; } void inline one() { int n; scanf("%d", &n); int min_odd = INF; int sum = 0; REP (i, n) { int a; scanf("%d", &a); sum += a; if (a % 2 == 1) { min_odd = min(min_odd, a); } } int result = get_max_kieszonkowe(sum, min_odd); if (result > 0) { printf("%d\n", result); } else { puts("NIESTETY"); } } int main() { //int z; scanf("%d", &z); while(z--) one(); } |