#include<bits/stdc++.h> #define FOR(i,s,e) for(int i=s;i<=e;i++) #define FORD(i,s,e) for(int i=s;i>=e;i--) #define ALL(k) (k).begin(),(k).end() #define e1 first #define e2 second #define MP make_pair #define PB push_back using namespace std; typedef long long LL; typedef pair<int,int> PII; typedef pair<LL,LL> PLL; typedef pair<int,PII> PIP; const int INF=(int)1e9+696969; main(){ int n;scanf("%d",&n); LL suma=0; int minnp=INF; FOR(i,1,n){ int a;scanf("%d",&a); suma+=a; if(a%2) minnp=min(minnp,a); } if(suma%2) suma-=minnp; printf(suma==0?"NIESTETY\n":"%lld\n",suma); }
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 | #include<bits/stdc++.h> #define FOR(i,s,e) for(int i=s;i<=e;i++) #define FORD(i,s,e) for(int i=s;i>=e;i--) #define ALL(k) (k).begin(),(k).end() #define e1 first #define e2 second #define MP make_pair #define PB push_back using namespace std; typedef long long LL; typedef pair<int,int> PII; typedef pair<LL,LL> PLL; typedef pair<int,PII> PIP; const int INF=(int)1e9+696969; main(){ int n;scanf("%d",&n); LL suma=0; int minnp=INF; FOR(i,1,n){ int a;scanf("%d",&a); suma+=a; if(a%2) minnp=min(minnp,a); } if(suma%2) suma-=minnp; printf(suma==0?"NIESTETY\n":"%lld\n",suma); } |