#include<iostream> using namespace std; int main() { long long n, sum, counter, a, odd, i; sum = 0; odd = 1000; counter = 0; cin >> n; for( i = 0; i < n; i++) { cin >> a; sum += a; if (a%2 != 0) { counter++; if (a < odd) odd = a; } } if (counter > 0 && counter % 2 != 0) sum -= odd; if(sum == 0) printf("NIESTETY"); else cout << 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 | #include<iostream> using namespace std; int main() { long long n, sum, counter, a, odd, i; sum = 0; odd = 1000; counter = 0; cin >> n; for( i = 0; i < n; i++) { cin >> a; sum += a; if (a%2 != 0) { counter++; if (a < odd) odd = a; } } if (counter > 0 && counter % 2 != 0) sum -= odd; if(sum == 0) printf("NIESTETY"); else cout << sum; return 0; } |