#include<iostream> using namespace std; int main() { int n; long long suma = 0; cin >> n; //int *tab = new int[n]; int pom, min=1000000; for (int i = 0; i < n; i++) { cin >> pom; suma += pom; if (pom % 2 == 1 && pom < min) min = pom; } if (suma % 2 == 0) cout << suma; else if (min != 1000000 && suma - min > 0) cout << (suma - min); 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 | #include<iostream> using namespace std; int main() { int n; long long suma = 0; cin >> n; //int *tab = new int[n]; int pom, min=1000000; for (int i = 0; i < n; i++) { cin >> pom; suma += pom; if (pom % 2 == 1 && pom < min) min = pom; } if (suma % 2 == 0) cout << suma; else if (min != 1000000 && suma - min > 0) cout << (suma - min); else cout << "NIESTETY"; return 0; } |