#include <vector> #include <list> #include <map> #include <set> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> #include <iostream> #include <string> #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define FORD(i,a,b) for(int i=(a);i>=(b);--i) #define REP(i,a) FOR(i,0,a) #define MP make_pair #define PB push_back #define ST first #define ND second using namespace std; typedef vector<int> VI; typedef vector<VI> VVI; typedef pair<int, int> PII; typedef vector<PII> VII; typedef long long int LL; typedef unsigned long long int ULL; int n; int sum = 0; int min_odd = 9999; int num_odd = 0; int main() { scanf("%d", &n); int x; for (int i = 0 ; i < n; ++i) { scanf("%d", &x); sum += x; if (x % 2 == 1) { ++num_odd; min_odd = min(x, min_odd); } } if (n == 1 && num_odd == 1) { printf("NIESTETY\n"); } else if (num_odd % 2 == 0) { printf("%d\n", sum); } else { printf("%d\n", sum - min_odd); } 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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> #include <iostream> #include <string> #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define FORD(i,a,b) for(int i=(a);i>=(b);--i) #define REP(i,a) FOR(i,0,a) #define MP make_pair #define PB push_back #define ST first #define ND second using namespace std; typedef vector<int> VI; typedef vector<VI> VVI; typedef pair<int, int> PII; typedef vector<PII> VII; typedef long long int LL; typedef unsigned long long int ULL; int n; int sum = 0; int min_odd = 9999; int num_odd = 0; int main() { scanf("%d", &n); int x; for (int i = 0 ; i < n; ++i) { scanf("%d", &x); sum += x; if (x % 2 == 1) { ++num_odd; min_odd = min(x, min_odd); } } if (n == 1 && num_odd == 1) { printf("NIESTETY\n"); } else if (num_odd % 2 == 0) { printf("%d\n", sum); } else { printf("%d\n", sum - min_odd); } return 0; } |