#include <iostream> #include <vector> #include <algorithm> using namespace std; unsigned long long int s; int x[1000002]; int main() { ios_base::sync_with_stdio(false); int a; cin>>a; for(int i=0;i<a;i++) { cin>>x[i]; s+=x[i]; } if(s%2==0) cout<<s; else { if (a==1) cout<<"NIESTETY"; else { sort(x,x+a); for(int i=0;i<a;i++) if((s-x[i])%2==0) {cout<<s-x[i]; break;} } } 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 | #include <iostream> #include <vector> #include <algorithm> using namespace std; unsigned long long int s; int x[1000002]; int main() { ios_base::sync_with_stdio(false); int a; cin>>a; for(int i=0;i<a;i++) { cin>>x[i]; s+=x[i]; } if(s%2==0) cout<<s; else { if (a==1) cout<<"NIESTETY"; else { sort(x,x+a); for(int i=0;i<a;i++) if((s-x[i])%2==0) {cout<<s-x[i]; break;} } } return 0; } |