#include<cstdio> using namespace std; int main() { int a_i,min_odd=1001;// 1<=a_i<=1001 int sum=0; bool is_odd=0; int N; scanf("%d",&N); while(N>0) { scanf("%d",&a_i); sum+=a_i; if(a_i%2==1) { is_odd=(is_odd+1)%2; if(a_i<min_odd)min_odd=a_i; } N--; } if(!is_odd) printf("%d",sum); else { if(min_odd==sum) printf("NIESTETY"); else printf("%d",sum-min_odd); } 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 34 35 | #include<cstdio> using namespace std; int main() { int a_i,min_odd=1001;// 1<=a_i<=1001 int sum=0; bool is_odd=0; int N; scanf("%d",&N); while(N>0) { scanf("%d",&a_i); sum+=a_i; if(a_i%2==1) { is_odd=(is_odd+1)%2; if(a_i<min_odd)min_odd=a_i; } N--; } if(!is_odd) printf("%d",sum); else { if(min_odd==sum) printf("NIESTETY"); else printf("%d",sum-min_odd); } return 0; } |