#include <cstdlib> #include <iostream> using namespace std; int main(int argc, char *argv[]) { int a,lowest=0,ile=0,input, ilenp=0; cin >> a; int c=0; for(int b=0; b < a;b++){ cin >> input; ile+=input; if(input%2==1) { if(c==0) lowest = input; lowest = min(lowest,input); c++; ilenp++; } } if(ilenp==1 && a==1){ cout << "NIESTETY"; return false; } if(ile%2==1) ile=ile-lowest; cout << ile; return false; }
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 | #include <cstdlib> #include <iostream> using namespace std; int main(int argc, char *argv[]) { int a,lowest=0,ile=0,input, ilenp=0; cin >> a; int c=0; for(int b=0; b < a;b++){ cin >> input; ile+=input; if(input%2==1) { if(c==0) lowest = input; lowest = min(lowest,input); c++; ilenp++; } } if(ilenp==1 && a==1){ cout << "NIESTETY"; return false; } if(ile%2==1) ile=ile-lowest; cout << ile; return false; } |