#include <iostream> using namespace std; int nmin; long long suma; bool nb=false; int main() { ios_base::sync_with_stdio(0); int n, we; cin>>n; if(n==1) { cin>>we; if(we%2==0) cout<<we; else cout<<"NIESTETY"; return 0; } for(int i=0; i<n; i++) { //cout<<"[]"<<nmin<<endl; cin>>we; suma+=we; if(we%2==1) { if(nb) { if(we<nmin) nmin=we; } else { nmin=we; nb=true; } } } if(suma%2==1) cout<<suma-nmin; else cout<<suma; 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 44 45 46 47 48 49 50 | #include <iostream> using namespace std; int nmin; long long suma; bool nb=false; int main() { ios_base::sync_with_stdio(0); int n, we; cin>>n; if(n==1) { cin>>we; if(we%2==0) cout<<we; else cout<<"NIESTETY"; return 0; } for(int i=0; i<n; i++) { //cout<<"[]"<<nmin<<endl; cin>>we; suma+=we; if(we%2==1) { if(nb) { if(we<nmin) nmin=we; } else { nmin=we; nb=true; } } } if(suma%2==1) cout<<suma-nmin; else cout<<suma; return 0; } |