#include <bits/stdc++.h>
using namespace std;
template<typename T>
inline ostream& operator<< (ostream& out, const vector<T>& data) {
out << data[0];
for( auto it = data.begin()+1; it != data.end(); it++ )
out << ' ' << *it;
return out;
}
template<typename T>
inline istream& operator>> (istream& in, vector<T>& data) {
for( auto &v : data )
in >> v;
return in;
}
void test() {
int n, sum = 0, min_odd = numeric_limits<int>::max();
cin >> n;
while( n --> 0 ) {
int v;
cin >> v;
sum += v;
if( v%2 == 1 and v < min_odd )
min_odd = v;
}
if( sum%2 == 1 )
sum -= min_odd;
if( sum == 0 )
cout << "NIESTETY\n";
else
cout << sum << '\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int T = 1;
//cin >> T;
while( T --> 0 )
test();
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 49 | #include <bits/stdc++.h> using namespace std; template<typename T> inline ostream& operator<< (ostream& out, const vector<T>& data) { out << data[0]; for( auto it = data.begin()+1; it != data.end(); it++ ) out << ' ' << *it; return out; } template<typename T> inline istream& operator>> (istream& in, vector<T>& data) { for( auto &v : data ) in >> v; return in; } void test() { int n, sum = 0, min_odd = numeric_limits<int>::max(); cin >> n; while( n --> 0 ) { int v; cin >> v; sum += v; if( v%2 == 1 and v < min_odd ) min_odd = v; } if( sum%2 == 1 ) sum -= min_odd; if( sum == 0 ) cout << "NIESTETY\n"; else cout << sum << '\n'; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int T = 1; //cin >> T; while( T --> 0 ) test(); return 0; } |
English