#include <iostream> #include <vector> #include <algorithm> using namespace std; #define nm long long int #define unm unsigned long long int #define uint unsigned int vector<uint> banknoty; unm sm = 0, temp, n; int main() { cin >> n; for(uint i=0;i<n;++i){ cin >> temp; if((temp&1)==0) sm += temp; else banknoty.push_back(temp); } sort(banknoty.begin(), banknoty.end(), greater<int>()); for(uint i=0;i<2*(banknoty.size()/2);++i) sm += banknoty[i]; if(!sm) cout << "NIESTETY\n"; else cout << sm << "\n"; 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 | #include <iostream> #include <vector> #include <algorithm> using namespace std; #define nm long long int #define unm unsigned long long int #define uint unsigned int vector<uint> banknoty; unm sm = 0, temp, n; int main() { cin >> n; for(uint i=0;i<n;++i){ cin >> temp; if((temp&1)==0) sm += temp; else banknoty.push_back(temp); } sort(banknoty.begin(), banknoty.end(), greater<int>()); for(uint i=0;i<2*(banknoty.size()/2);++i) sm += banknoty[i]; if(!sm) cout << "NIESTETY\n"; else cout << sm << "\n"; return 0; } |