#include <iostream> using namespace std; int main() { int ilebanknotow = 0, minimum = 1001; unsigned long long int suma = 0; bool parzyste = true; cin >> ilebanknotow; for (int i = 0; i < ilebanknotow; i++) { int nominal = 0; cin >> nominal; suma += nominal; if (nominal % 2 != 0) { if (nominal < minimum) minimum = nominal; if (parzyste == false ) parzyste = true; else parzyste = false; } } if (parzyste == false) suma = suma - minimum; if (suma > 0) cout << suma << "\n"; else cout << "NIESTETY\n"; 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 | #include <iostream> using namespace std; int main() { int ilebanknotow = 0, minimum = 1001; unsigned long long int suma = 0; bool parzyste = true; cin >> ilebanknotow; for (int i = 0; i < ilebanknotow; i++) { int nominal = 0; cin >> nominal; suma += nominal; if (nominal % 2 != 0) { if (nominal < minimum) minimum = nominal; if (parzyste == false ) parzyste = true; else parzyste = false; } } if (parzyste == false) suma = suma - minimum; if (suma > 0) cout << suma << "\n"; else cout << "NIESTETY\n"; return 0; } |