#include<iostream> using namespace std; long long int a,b,c=1001,d,wyn; int main(){ cin>>a; for(int i=0;i<a;i++){ cin>>b; if(b%2==1){ d=(d+1)%2; if(b<c)c=b;} wyn=wyn+b; } if(d==0)cout<<wyn; if(d==1){ wyn=wyn-c; if(wyn==0)cout<<"NIESTETY"; else cout<<wyn; } return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include<iostream> using namespace std; long long int a,b,c=1001,d,wyn; int main(){ cin>>a; for(int i=0;i<a;i++){ cin>>b; if(b%2==1){ d=(d+1)%2; if(b<c)c=b;} wyn=wyn+b; } if(d==0)cout<<wyn; if(d==1){ wyn=wyn-c; if(wyn==0)cout<<"NIESTETY"; else cout<<wyn; } return 0; } |