#include<cstdio> #include<algorithm> using namespace std; int tab[1000005]; int main(){ int n, pom, s = 0, ak = 0; scanf("%d", &n); for(int i = 0; i < n; i++){ scanf("%d", &pom); if(pom % 2 == 0)s += pom; else{ tab[ak++] = pom; } } //printf("%d", s); sort(tab, tab + ak); if(ak % 2 == 1)pom = 1; else pom = 0; for(int i = pom; i < ak; i++)s += tab[i]; if(s == 0)printf("NIESTETY"); else printf("%d", s); }
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 | #include<cstdio> #include<algorithm> using namespace std; int tab[1000005]; int main(){ int n, pom, s = 0, ak = 0; scanf("%d", &n); for(int i = 0; i < n; i++){ scanf("%d", &pom); if(pom % 2 == 0)s += pom; else{ tab[ak++] = pom; } } //printf("%d", s); sort(tab, tab + ak); if(ak % 2 == 1)pom = 1; else pom = 0; for(int i = pom; i < ak; i++)s += tab[i]; if(s == 0)printf("NIESTETY"); else printf("%d", s); } |