#include <bits/stdc++.h> using namespace std; #define fru(j,n) for(int j=0; j<(n); ++j) #define tr(it,v) for(typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it) #define x first #define y second #define pb push_back #define mp make_pair #define ALL(G) (G).begin(),(G).end() typedef long long ll; typedef double D; typedef pair<int,int> pii; typedef vector<int> vi; const int inft = 1000000009; const int MAXN = 1000006; void solve() { int n,ln=0,minn=inft,sum=0; scanf("%d",&n); fru(i,n){ int a; scanf("%d",&a); sum+=a; if(a%2){ ln++; minn=min(minn,a); } } if(ln%2)sum-=minn; if(sum)printf("%d\n",sum); else puts("NIESTETY"); } int main() { // freopen("input.in", "r", stdin); // freopen("output.out", "w", stdout); int t=1; // scanf("%d",&t); fru(i,t) solve(); 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 33 34 35 36 37 38 39 40 41 42 43 44 45 | #include <bits/stdc++.h> using namespace std; #define fru(j,n) for(int j=0; j<(n); ++j) #define tr(it,v) for(typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it) #define x first #define y second #define pb push_back #define mp make_pair #define ALL(G) (G).begin(),(G).end() typedef long long ll; typedef double D; typedef pair<int,int> pii; typedef vector<int> vi; const int inft = 1000000009; const int MAXN = 1000006; void solve() { int n,ln=0,minn=inft,sum=0; scanf("%d",&n); fru(i,n){ int a; scanf("%d",&a); sum+=a; if(a%2){ ln++; minn=min(minn,a); } } if(ln%2)sum-=minn; if(sum)printf("%d\n",sum); else puts("NIESTETY"); } int main() { // freopen("input.in", "r", stdin); // freopen("output.out", "w", stdout); int t=1; // scanf("%d",&t); fru(i,t) solve(); return 0; } |