#include <cstdio> #include <iostream> using namespace std; #define UNDEF 1001 int main() { int n, sum = 0; int minodd = UNDEF; scanf("%d", &n); for(int i = 1; i <= n; i++) { int a; scanf("%d", &a); sum += a; if(a % 2 == 1) minodd = min(minodd, a); } if(sum % 2 == 0) printf("%d\n", sum); else if(minodd != UNDEF && sum-minodd > 0) printf("%d\n", sum-minodd); else printf("NIESTETY\n"); }
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 | #include <cstdio> #include <iostream> using namespace std; #define UNDEF 1001 int main() { int n, sum = 0; int minodd = UNDEF; scanf("%d", &n); for(int i = 1; i <= n; i++) { int a; scanf("%d", &a); sum += a; if(a % 2 == 1) minodd = min(minodd, a); } if(sum % 2 == 0) printf("%d\n", sum); else if(minodd != UNDEF && sum-minodd > 0) printf("%d\n", sum-minodd); else printf("NIESTETY\n"); } |