#include <iostream> #include <stdio.h> using namespace std; int main() { //ios_base::sync_with_stdio(0); long long suma = 0; int a,b; //cin >> a; scanf("%d",&(a)); int minn = 1001; int liczbaniep = 0; for(int i = 0; i< a; i++) { scanf("%d",&(b)); if(b%2==1) { liczbaniep++; if(minn>b) minn=b; } suma+=b; } if(liczbaniep%2==1 && a==1) printf("NIESTETY"); // cout << "NIESTETY"; else if(liczbaniep%2==0) printf("%lld",suma); //cout << suma; else if(liczbaniep%2==1 && a!=1) printf("%lld",suma-minn);//cout << suma - minn; 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 | #include <iostream> #include <stdio.h> using namespace std; int main() { //ios_base::sync_with_stdio(0); long long suma = 0; int a,b; //cin >> a; scanf("%d",&(a)); int minn = 1001; int liczbaniep = 0; for(int i = 0; i< a; i++) { scanf("%d",&(b)); if(b%2==1) { liczbaniep++; if(minn>b) minn=b; } suma+=b; } if(liczbaniep%2==1 && a==1) printf("NIESTETY"); // cout << "NIESTETY"; else if(liczbaniep%2==0) printf("%lld",suma); //cout << suma; else if(liczbaniep%2==1 && a!=1) printf("%lld",suma-minn);//cout << suma - minn; return 0; } |