#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(string args[]){
long suma = 0;
int n;
cin >> n;
int minnp = 2147483647;
int nnp = 0;
short nom;
for (int i = 0; i < n; i++){
cin >> nom;
if (nom % 2 == 0)
suma += nom;
else{
suma += nom;
nnp++;
if (nom < minnp)
minnp = nom;
}
}
if (n == 1 && (suma % 2 == 1))
cout << "NIESTETY" << endl;
else
{
if (nnp % 2 == 1){
suma = suma - minnp;
cout << suma << endl;
}
else
{
cout << suma << endl;
}
}
system("PAUSE");
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 | #include <iostream> #include <string> #include <math.h> using namespace std; int main(string args[]){ long suma = 0; int n; cin >> n; int minnp = 2147483647; int nnp = 0; short nom; for (int i = 0; i < n; i++){ cin >> nom; if (nom % 2 == 0) suma += nom; else{ suma += nom; nnp++; if (nom < minnp) minnp = nom; } } if (n == 1 && (suma % 2 == 1)) cout << "NIESTETY" << endl; else { if (nnp % 2 == 1){ suma = suma - minnp; cout << suma << endl; } else { cout << suma << endl; } } system("PAUSE"); return 0; } |
English