#include <iostream>
using namespace std;
int t[1000000];
int main ()
{
int n;
cin >> n;
long long suma = 0, max =0;
for(int i = 0; i < n; i++){
cin >> t[i];
suma += t[i];
}
if(n==1 && t[0]%2!= 0)
cout << "NIESTETY";
else if(suma%2==0)
cout << suma;
else {
for (int j = 0; j < n; j++){
if((suma-t[j])%2==0 && (suma-t[j]) > max){
max = (suma - t[j]);
}
}
cout << max;
}
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 | #include <iostream> using namespace std; int t[1000000]; int main () { int n; cin >> n; long long suma = 0, max =0; for(int i = 0; i < n; i++){ cin >> t[i]; suma += t[i]; } if(n==1 && t[0]%2!= 0) cout << "NIESTETY"; else if(suma%2==0) cout << suma; else { for (int j = 0; j < n; j++){ if((suma-t[j])%2==0 && (suma-t[j]) > max){ max = (suma - t[j]); } } cout << max; } return 0; } |
English