#include <cstdio> #include <vector> using namespace std; int main() { int num_bills; long long int sum = 0; int x; vector<int> input; int min_odd = 1000001; scanf ("%d",&num_bills); for(int i = 0; i < num_bills; i++){ scanf ("%d",&x); input.push_back(x); } for(int i=0; i < num_bills; i++){ int nominal = input.at(i); if(nominal % 2 == 1 && nominal < min_odd){ min_odd = nominal; } sum += nominal; } if(sum % 2 == 0){ printf("%lld",sum); }else{ if(num_bills == 1){ printf("%s","NIESTETY"); }else{ sum -= min_odd; printf("%lld",sum); } } }
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 <cstdio> #include <vector> using namespace std; int main() { int num_bills; long long int sum = 0; int x; vector<int> input; int min_odd = 1000001; scanf ("%d",&num_bills); for(int i = 0; i < num_bills; i++){ scanf ("%d",&x); input.push_back(x); } for(int i=0; i < num_bills; i++){ int nominal = input.at(i); if(nominal % 2 == 1 && nominal < min_odd){ min_odd = nominal; } sum += nominal; } if(sum % 2 == 0){ printf("%lld",sum); }else{ if(num_bills == 1){ printf("%s","NIESTETY"); }else{ sum -= min_odd; printf("%lld",sum); } } } |