#include<iostream> #include<cstdio> int n,s, a,mi; bool np=0; using namespace std; int main () { cin>>n; mi=1000; s=0; for(int i=0;i<n;i++) { scanf("%d", &a); s+=a; if(a%2!=0&&a<mi) { np=1; mi=a; } } if(s%2==0)cout<<s<<endl; else if(np==1&&n>1)cout<<s-a<<endl; else cout<<"NIESTETY"<<endl; 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 | #include<iostream> #include<cstdio> int n,s, a,mi; bool np=0; using namespace std; int main () { cin>>n; mi=1000; s=0; for(int i=0;i<n;i++) { scanf("%d", &a); s+=a; if(a%2!=0&&a<mi) { np=1; mi=a; } } if(s%2==0)cout<<s<<endl; else if(np==1&&n>1)cout<<s-a<<endl; else cout<<"NIESTETY"<<endl; return 0; } |