#include<bits/stdc++.h> using namespace std; int main(){ int n,a,sum=0,mini=2000006; scanf("%d",&n); while(n--){ scanf("%d",&a); sum+=a; if(a%2) mini=min(mini,a); } if(sum%2) sum-=mini; if(!(sum%2) && sum>0) printf("%d",sum); else printf("NIESTETY"); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include<bits/stdc++.h> using namespace std; int main(){ int n,a,sum=0,mini=2000006; scanf("%d",&n); while(n--){ scanf("%d",&a); sum+=a; if(a%2) mini=min(mini,a); } if(sum%2) sum-=mini; if(!(sum%2) && sum>0) printf("%d",sum); else printf("NIESTETY"); return 0; } |