#include <bits/stdc++.h> using namespace std; #define REP(i,a,b) for(int i=(a);i<=(b);++i) #define FORI(i,n) REP(i,1,n) #define FOR(i,n) REP(i,0,int(n)-1) #define mp make_pair #define pb push_back #define pii pair<int,int> #define vi vector<int> #define ll long long #define SZ(x) int((x).size()) #define DBG(v) cerr << #v << " = " << (v) << endl; #define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) #define SORT(X) sort(X.begin(),X.end()) #define fi first #define se second int main () { int n; scanf("%d",&n); int nn = 10001; int sum = 0; FOR(i,n){ int a; scanf("%d",&a); if(a%2) nn = min(a,nn); sum += a; } if(sum%2 == 0){ printf("%d\n", sum); } else{ if(nn < 1000 && sum-nn > 0) printf("%d\n", sum-nn); else printf("NIESTETY\n"); } }
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 | #include <bits/stdc++.h> using namespace std; #define REP(i,a,b) for(int i=(a);i<=(b);++i) #define FORI(i,n) REP(i,1,n) #define FOR(i,n) REP(i,0,int(n)-1) #define mp make_pair #define pb push_back #define pii pair<int,int> #define vi vector<int> #define ll long long #define SZ(x) int((x).size()) #define DBG(v) cerr << #v << " = " << (v) << endl; #define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) #define SORT(X) sort(X.begin(),X.end()) #define fi first #define se second int main () { int n; scanf("%d",&n); int nn = 10001; int sum = 0; FOR(i,n){ int a; scanf("%d",&a); if(a%2) nn = min(a,nn); sum += a; } if(sum%2 == 0){ printf("%d\n", sum); } else{ if(nn < 1000 && sum-nn > 0) printf("%d\n", sum-nn); else printf("NIESTETY\n"); } } |