#include <iostream> //#include <conio.h> using namespace std; int n; int main() { cin>>n; int t[n]; for(int i = 0; i<n; i++) cin>>t[i]; int s = 0; for(int i = 0; i<n; i++) s = s + t[i]; if(s%2 == 0) cout<<s; else { int m; for(int i = 0; i<n; i++) {if(t[i]%2 == 1) {m = t[i]; break;}} for(int i = 0; i<n; i++) { if(t[i]%2 == 1 && t[i]<m) m = t[i]; } s = s - m; if(s!=0) cout<<s; else cout<<"NIESTETY"; } //getch(); }
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 | #include <iostream> //#include <conio.h> using namespace std; int n; int main() { cin>>n; int t[n]; for(int i = 0; i<n; i++) cin>>t[i]; int s = 0; for(int i = 0; i<n; i++) s = s + t[i]; if(s%2 == 0) cout<<s; else { int m; for(int i = 0; i<n; i++) {if(t[i]%2 == 1) {m = t[i]; break;}} for(int i = 0; i<n; i++) { if(t[i]%2 == 1 && t[i]<m) m = t[i]; } s = s - m; if(s!=0) cout<<s; else cout<<"NIESTETY"; } //getch(); } |