#include <iostream> using namespace std; int n; int main() { std::ios_base::sync_with_stdio(false); cin>>n; long sum=0; long smallestOdd=1000; long a; for(int k=0;k<n;k++) { cin>>a; sum+=a; if(a%2!=0 && a < smallestOdd) smallestOdd = a; } if (sum%2==0) cout<<sum<<endl; else { if (smallestOdd == 1000 || n==1) cout<<"NIESTETY"<<endl; else cout<<sum-smallestOdd<<endl; } 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 | #include <iostream> using namespace std; int n; int main() { std::ios_base::sync_with_stdio(false); cin>>n; long sum=0; long smallestOdd=1000; long a; for(int k=0;k<n;k++) { cin>>a; sum+=a; if(a%2!=0 && a < smallestOdd) smallestOdd = a; } if (sum%2==0) cout<<sum<<endl; else { if (smallestOdd == 1000 || n==1) cout<<"NIESTETY"<<endl; else cout<<sum-smallestOdd<<endl; } return 0; } |