#include <iostream> using namespace std; int main() { int n, temp; int sum = 0; int lowest = 1001; cin>>n; for(int i=0; i<n; ++i){ cin>>temp; sum += temp; if(lowest > temp && temp % 2 == 1) lowest = temp; } if (sum % 2 == 0){ cout<<sum<<endl; } else{ if(lowest != 1001 && n > 1) cout<<(sum - lowest)<<endl; else cout<<"NIESTETY"<<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 | #include <iostream> using namespace std; int main() { int n, temp; int sum = 0; int lowest = 1001; cin>>n; for(int i=0; i<n; ++i){ cin>>temp; sum += temp; if(lowest > temp && temp % 2 == 1) lowest = temp; } if (sum % 2 == 0){ cout<<sum<<endl; } else{ if(lowest != 1001 && n > 1) cout<<(sum - lowest)<<endl; else cout<<"NIESTETY"<<endl; } return 0; } |