#include <stdio.h> int main() { int N, sum = 0, min, tmp = -1; scanf("%d", &N); for (int i=0; i<N; i++) { scanf("%d", &tmp); if (tmp%2==1 && (min<-1 || tmp<min)) min = tmp; sum += tmp; } if (sum % 2 == 1) { if (min < 0 || N==1) { printf("NIESTETY"); return 0; } sum -= min; } 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 | #include <stdio.h> int main() { int N, sum = 0, min, tmp = -1; scanf("%d", &N); for (int i=0; i<N; i++) { scanf("%d", &tmp); if (tmp%2==1 && (min<-1 || tmp<min)) min = tmp; sum += tmp; } if (sum % 2 == 1) { if (min < 0 || N==1) { printf("NIESTETY"); return 0; } sum -= min; } printf("%d", sum); return 0; } |