#include<iostream> #include<cstdio> #include<cmath> using namespace std; int main(){ unsigned long long int suma = 0, n, n2, min_np = 0, banknot; bool np = false; cin >> n; n2 = n; while (n--) { cin >> banknot; suma += banknot; if (banknot % 2 == 1){ np = !np; if (min_np == 0) min_np = banknot; else if (min_np > banknot) min_np = banknot; } } if (n2 == 1 && np) cout << "NIESTETY\n"; else cout << suma - (np ? min_np : 0) << endl; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include<iostream> #include<cstdio> #include<cmath> using namespace std; int main(){ unsigned long long int suma = 0, n, n2, min_np = 0, banknot; bool np = false; cin >> n; n2 = n; while (n--) { cin >> banknot; suma += banknot; if (banknot % 2 == 1){ np = !np; if (min_np == 0) min_np = banknot; else if (min_np > banknot) min_np = banknot; } } if (n2 == 1 && np) cout << "NIESTETY\n"; else cout << suma - (np ? min_np : 0) << endl; } |