#include<cstdio> #include<algorithm> #include<vector> #include<set> #include<map> #include<queue> #include<cmath> #include<iostream> #include<string> using namespace std; #define F first #define S second #define MP make_pair #define PB push_back #define LL long long #define PII pair<int, int> #define PLL pair<LL, LL> int n, sum, mini=1000001; int main() { //ios_base::sync_with_stdio(0); scanf("%d", &n); for(int i=0; i<n; i++) { int a; scanf("%d", &a); sum+=a; if(a%2) mini=min(mini, a); } if(sum%2==0) printf("%d\n", sum); else { if(n==1) printf("NIESTETY\n"); else printf("%d\n", sum-mini); } 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 | #include<cstdio> #include<algorithm> #include<vector> #include<set> #include<map> #include<queue> #include<cmath> #include<iostream> #include<string> using namespace std; #define F first #define S second #define MP make_pair #define PB push_back #define LL long long #define PII pair<int, int> #define PLL pair<LL, LL> int n, sum, mini=1000001; int main() { //ios_base::sync_with_stdio(0); scanf("%d", &n); for(int i=0; i<n; i++) { int a; scanf("%d", &a); sum+=a; if(a%2) mini=min(mini, a); } if(sum%2==0) printf("%d\n", sum); else { if(n==1) printf("NIESTETY\n"); else printf("%d\n", sum-mini); } return 0; } |