#include <stdio.h> using namespace std; int n; int banknot; int nominaly[1001]; int suma_portfel = 0; int main() { scanf("%d", &n); for(int i = 0; i < n; i++) { scanf("%d", &banknot); nominaly[banknot]++; suma_portfel += banknot; } if(suma_portfel%2 == 0) printf("%d\n", suma_portfel); else { for(int i = 1; ; i += 2) { if(nominaly[i] > 0) { suma_portfel -= i; break; } } if(suma_portfel > 0) printf("%d\n", suma_portfel); else printf("NIESTETY\n"); } 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 | #include <stdio.h> using namespace std; int n; int banknot; int nominaly[1001]; int suma_portfel = 0; int main() { scanf("%d", &n); for(int i = 0; i < n; i++) { scanf("%d", &banknot); nominaly[banknot]++; suma_portfel += banknot; } if(suma_portfel%2 == 0) printf("%d\n", suma_portfel); else { for(int i = 1; ; i += 2) { if(nominaly[i] > 0) { suma_portfel -= i; break; } } if(suma_portfel > 0) printf("%d\n", suma_portfel); else printf("NIESTETY\n"); } return 0; } |