#include <iostream> #include <climits> using namespace std; int main() { int ilosc_banknotow; cin >> ilosc_banknotow; int min_nieparzysty = INT_MAX; long long suma = 0; for (int i = 0; i < ilosc_banknotow; ++i) { int banknot; cin >> banknot; suma += banknot; if (banknot % 2 == 1 && banknot < min_nieparzysty) min_nieparzysty = banknot; } if (suma % 2 == 1) suma -= min_nieparzysty; if (suma > 0) cout << suma; else cout << "NIESTETY"; }
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 | #include <iostream> #include <climits> using namespace std; int main() { int ilosc_banknotow; cin >> ilosc_banknotow; int min_nieparzysty = INT_MAX; long long suma = 0; for (int i = 0; i < ilosc_banknotow; ++i) { int banknot; cin >> banknot; suma += banknot; if (banknot % 2 == 1 && banknot < min_nieparzysty) min_nieparzysty = banknot; } if (suma % 2 == 1) suma -= min_nieparzysty; if (suma > 0) cout << suma; else cout << "NIESTETY"; } |