#include <cstdio> using namespace std; int main(){ long int suma = 0; int n; int minimum = 1001; //strażnik int tmp; scanf("%d", &n); for (int i = 0; i < n; i++){ scanf("%d", &tmp); suma += tmp; if( tmp < minimum && tmp % 2 == 1) minimum = tmp; } if (suma % 2 == 0) printf("%ld", suma); else if (n == 1) printf("NIESTETY"); else printf("%ld", suma - minimum); 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 | #include <cstdio> using namespace std; int main(){ long int suma = 0; int n; int minimum = 1001; //strażnik int tmp; scanf("%d", &n); for (int i = 0; i < n; i++){ scanf("%d", &tmp); suma += tmp; if( tmp < minimum && tmp % 2 == 1) minimum = tmp; } if (suma % 2 == 0) printf("%ld", suma); else if (n == 1) printf("NIESTETY"); else printf("%ld", suma - minimum); return 0; } |