#include <iostream> int mina,n,i,a; long int suma; using namespace std; int main() { ios_base::sync_with_stdio(0); cin>>n; suma=0;mina=1000; for (i=1;i<=n;i++) {cin>>a; suma=suma+a; if ((a%2==1)&&(a<mina)) mina=a; } if (suma%2==0) cout<<suma; if ((suma%2==1)&&(suma-mina>0)) cout<<suma-mina; if ((suma%2==1)&&(suma-mina<=0)) cout<<"NIESTETY"; 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 | #include <iostream> int mina,n,i,a; long int suma; using namespace std; int main() { ios_base::sync_with_stdio(0); cin>>n; suma=0;mina=1000; for (i=1;i<=n;i++) {cin>>a; suma=suma+a; if ((a%2==1)&&(a<mina)) mina=a; } if (suma%2==0) cout<<suma; if ((suma%2==1)&&(suma-mina>0)) cout<<suma-mina; if ((suma%2==1)&&(suma-mina<=0)) cout<<"NIESTETY"; return 0; } |