#include <cstdio> int main() { int suma =0 , minNP = 1000005, iloscNP = 0, n, a; scanf(" %d",&n); for(int i=0; i<n; i++) { scanf(" %d",&a); if(a%2 == 1){ if( minNP > a) minNP = a; iloscNP ++; } suma += a; } if((n==1) && (iloscNP==1)) { printf("NIESTETY\n"); return 0; } else { if(iloscNP%2==1) suma -= minNP; } printf("%d\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 | #include <cstdio> int main() { int suma =0 , minNP = 1000005, iloscNP = 0, n, a; scanf(" %d",&n); for(int i=0; i<n; i++) { scanf(" %d",&a); if(a%2 == 1){ if( minNP > a) minNP = a; iloscNP ++; } suma += a; } if((n==1) && (iloscNP==1)) { printf("NIESTETY\n"); return 0; } else { if(iloscNP%2==1) suma -= minNP; } printf("%d\n",suma); return 0; } |