#include <iostream> using namespace std; int a[1001]; int main(){ int n,b; long long s = 0; cin>>n; for(int i =0;i<n;i++){ cin>>b; s+=b; a[b]++; } if(s%2==0) cout<<s<<"\n"; else{ int ok = 0; for(int j=1;j<1000;j+=2) if(a[j]>0 && s-j>0){ cout<<s-j<<"\n"; ok =1; break; } if(ok==0){ cout<<"NIESTETY\n"; } } 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 | #include <iostream> using namespace std; int a[1001]; int main(){ int n,b; long long s = 0; cin>>n; for(int i =0;i<n;i++){ cin>>b; s+=b; a[b]++; } if(s%2==0) cout<<s<<"\n"; else{ int ok = 0; for(int j=1;j<1000;j+=2) if(a[j]>0 && s-j>0){ cout<<s-j<<"\n"; ok =1; break; } if(ok==0){ cout<<"NIESTETY\n"; } } return 0; } |