#include <cstdio> #include <vector> using namespace std; int main(){ int n; scanf("%d",&n); long long int suma = 0; int smallest = -1; for(int i=0;i<n;++i){ int moneta; scanf("%d",&moneta); suma+=moneta; if(moneta%2==1){ if(smallest==-1 || moneta<smallest) smallest=moneta; } } if(suma%2==0){ printf("%lld\n",suma); } else{ suma-=smallest; if(suma==0) puts("NIESTETY"); else printf("%lld\n",suma); } 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 <cstdio> #include <vector> using namespace std; int main(){ int n; scanf("%d",&n); long long int suma = 0; int smallest = -1; for(int i=0;i<n;++i){ int moneta; scanf("%d",&moneta); suma+=moneta; if(moneta%2==1){ if(smallest==-1 || moneta<smallest) smallest=moneta; } } if(suma%2==0){ printf("%lld\n",suma); } else{ suma-=smallest; if(suma==0) puts("NIESTETY"); else printf("%lld\n",suma); } return 0; } |