#include <stdio.h> unsigned N; unsigned A[1000000]; unsigned sum; unsigned minNiep, niepCount; int main() { int i, val; scanf("%d", &N); sum = 0; minNiep = 1001; niepCount = 0; for(i = 0; i < N; i++) { scanf("%d", &val); if(val % 2 > 0) { if (val < minNiep) minNiep = val; niepCount ++; } sum += val; } if((N == 1) && (minNiep < 1001)) printf ("NIESTETY"); else { if(niepCount % 2 > 0) sum -= minNiep; printf("%d", sum); } 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 | #include <stdio.h> unsigned N; unsigned A[1000000]; unsigned sum; unsigned minNiep, niepCount; int main() { int i, val; scanf("%d", &N); sum = 0; minNiep = 1001; niepCount = 0; for(i = 0; i < N; i++) { scanf("%d", &val); if(val % 2 > 0) { if (val < minNiep) minNiep = val; niepCount ++; } sum += val; } if((N == 1) && (minNiep < 1001)) printf ("NIESTETY"); else { if(niepCount % 2 > 0) sum -= minNiep; printf("%d", sum); } return 0; } |