#include <cstdio> #include <map> #include <algorithm> #include <vector> #include <queue> using namespace std; typedef long long LL; typedef pair<LL,LL> PI; #define MP make_pair #define PB push_back #define SD second #define FT first int k,n,m,q; const int N = 100003; const LL INF = 2000000000000000000LL; int main() { scanf("%d",&n); LL suma = 0; LL min_nieparzyste=INF; LL ile_nieparzystych=0; for(int i=0;i<n;i++) { int a; scanf("%d",&a); if(a%2==0) suma+=a; else { min_nieparzyste = min(min_nieparzyste,(LL)a); ile_nieparzystych++; suma+=a; } } if(ile_nieparzystych % 2) suma-=min_nieparzyste; if(suma==0) printf("NIESTETY\n"); else printf("%lld\n", 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 | #include <cstdio> #include <map> #include <algorithm> #include <vector> #include <queue> using namespace std; typedef long long LL; typedef pair<LL,LL> PI; #define MP make_pair #define PB push_back #define SD second #define FT first int k,n,m,q; const int N = 100003; const LL INF = 2000000000000000000LL; int main() { scanf("%d",&n); LL suma = 0; LL min_nieparzyste=INF; LL ile_nieparzystych=0; for(int i=0;i<n;i++) { int a; scanf("%d",&a); if(a%2==0) suma+=a; else { min_nieparzyste = min(min_nieparzyste,(LL)a); ile_nieparzystych++; suma+=a; } } if(ile_nieparzystych % 2) suma-=min_nieparzyste; if(suma==0) printf("NIESTETY\n"); else printf("%lld\n", suma); return 0; } |