#include <iostream> using namespace std; int main() { long long int n,w=0,w2=0,a,minn=1000000,k=0; cin>>n; for(long long int i=0; i<n; i++) { cin>>a; if(a%2==0)w=w+a; else { w2=w2+a; minn=min(minn,a); k++; } } if(k%2==0)w=w+w2; else w=w+w2-minn; if(w==0)cout<<"NIESTETY"; else cout<<w; 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 | #include <iostream> using namespace std; int main() { long long int n,w=0,w2=0,a,minn=1000000,k=0; cin>>n; for(long long int i=0; i<n; i++) { cin>>a; if(a%2==0)w=w+a; else { w2=w2+a; minn=min(minn,a); k++; } } if(k%2==0)w=w+w2; else w=w+w2-minn; if(w==0)cout<<"NIESTETY"; else cout<<w; return 0; } |