/* Marcin 'Gregor' Gregorczyk * PA 2015, runda 1, zadanie Kieszonkowe */ #include <cstdio> using namespace std; int main() { int n, val, minVal = 1000, sum = 0; scanf("%d", &n); for(int i = 0; i < n; i++) { scanf("%d", &val); sum += val; if(val % 2 != 0 && val < minVal) minVal = val; } if(sum % 2 == 0) printf("%d\n", sum); else if(n == 1) printf("NIESTETY\n"); else printf("%d\n", sum - minVal); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | /* Marcin 'Gregor' Gregorczyk * PA 2015, runda 1, zadanie Kieszonkowe */ #include <cstdio> using namespace std; int main() { int n, val, minVal = 1000, sum = 0; scanf("%d", &n); for(int i = 0; i < n; i++) { scanf("%d", &val); sum += val; if(val % 2 != 0 && val < minVal) minVal = val; } if(sum % 2 == 0) printf("%d\n", sum); else if(n == 1) printf("NIESTETY\n"); else printf("%d\n", sum - minVal); return 0; } |