#include <cstdio> #include <vector> #include <algorithm> #include <climits> using namespace std; int min(int a, int b) { return a < b ? a : b; } int main() { int b,n,m,sum,odd_counter; scanf("%d", &n); m = INT_MAX; sum = odd_counter = 0; while (n--) { scanf("%d", &b); sum += b; if (b % 2 == 1) { odd_counter++; m = min(m, b); } } if (odd_counter % 2 == 1) { sum -= m; } if (sum == 0) { printf("NIESTETY\n"); } else { printf("%d\n", 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 34 | #include <cstdio> #include <vector> #include <algorithm> #include <climits> using namespace std; int min(int a, int b) { return a < b ? a : b; } int main() { int b,n,m,sum,odd_counter; scanf("%d", &n); m = INT_MAX; sum = odd_counter = 0; while (n--) { scanf("%d", &b); sum += b; if (b % 2 == 1) { odd_counter++; m = min(m, b); } } if (odd_counter % 2 == 1) { sum -= m; } if (sum == 0) { printf("NIESTETY\n"); } else { printf("%d\n", sum); } return 0; } |