#include <iostream>
//#include <stdio.h>
#include <vector>
#include <string>
//#include <fstream>
#include <map>
#include <algorithm>
using namespace std;
vector<int> odd;
//vector<vector<int> > possible(10,vector<int>() );
int main()
{
ios::sync_with_stdio(false);
//ifstream in("clocks.in");
//ofstream out("clocks.out");
int n;
cin >> n;
int sum=0;
while ( n-- ){
int cur; cin >> cur;
if ( cur%2==0 ){
sum+=cur;
}
else{
odd.push_back( cur );
}
}
sort( odd.begin(), odd.end() );
reverse( odd.begin(), odd.end() );
for ( int i=0; i+1 < odd.size(); i+=2 ){
sum+=odd[i]+odd[i+1];
}
if ( sum )
cout << sum << endl;
else
cout << "NIESTETY" << endl;
system( "pause" );
}
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 <iostream> //#include <stdio.h> #include <vector> #include <string> //#include <fstream> #include <map> #include <algorithm> using namespace std; vector<int> odd; //vector<vector<int> > possible(10,vector<int>() ); int main() { ios::sync_with_stdio(false); //ifstream in("clocks.in"); //ofstream out("clocks.out"); int n; cin >> n; int sum=0; while ( n-- ){ int cur; cin >> cur; if ( cur%2==0 ){ sum+=cur; } else{ odd.push_back( cur ); } } sort( odd.begin(), odd.end() ); reverse( odd.begin(), odd.end() ); for ( int i=0; i+1 < odd.size(); i+=2 ){ sum+=odd[i]+odd[i+1]; } if ( sum ) cout << sum << endl; else cout << "NIESTETY" << endl; system( "pause" ); } |
English