#include <iostream> using namespace std; long long int a, c, n, e, sum, naj=100000000000; int main () { cin>>n; for (int i=0; i<n; i++ ){ cin>>a; sum=sum+a; if (a<=naj && a%2==1) naj=a; } if (sum%2==0){ cout<<sum; } else if (sum==naj) cout<<"NIESTETY"; else cout<<sum-naj; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include <iostream> using namespace std; long long int a, c, n, e, sum, naj=100000000000; int main () { cin>>n; for (int i=0; i<n; i++ ){ cin>>a; sum=sum+a; if (a<=naj && a%2==1) naj=a; } if (sum%2==0){ cout<<sum; } else if (sum==naj) cout<<"NIESTETY"; else cout<<sum-naj; return 0; } |