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