#include <iostream> #include <vector> #include <algorithm> #include <queue> #include <utility> #define ll long long #define ld long double using namespace std; int main() { ll n; cin >> n; ll min_po_niep = 1001; ll suma = 0; for(ll i = 1; i <= n; i++) { ll a; cin >> a; if(a % 2 == 1) { min_po_niep = min(min_po_niep, a); } suma = suma + a; } if(suma % 2 == 0) { cout << suma << endl; } else { if(min_po_niep != 1001) { if(suma - min_po_niep != 0) cout << suma - min_po_niep << endl; else cout << "NIESTETY" << endl; } } 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #include <iostream> #include <vector> #include <algorithm> #include <queue> #include <utility> #define ll long long #define ld long double using namespace std; int main() { ll n; cin >> n; ll min_po_niep = 1001; ll suma = 0; for(ll i = 1; i <= n; i++) { ll a; cin >> a; if(a % 2 == 1) { min_po_niep = min(min_po_niep, a); } suma = suma + a; } if(suma % 2 == 0) { cout << suma << endl; } else { if(min_po_niep != 1001) { if(suma - min_po_niep != 0) cout << suma - min_po_niep << endl; else cout << "NIESTETY" << endl; } } return 0; } |