#include <cstdio>
#include <algorithm>
using namespace std;
int nom, n, result, waiting;
int main(){
scanf("%d",&n);
for(int i = 0; i < n; i++) {
scanf("%d",&nom);
if ((nom % 2) == 0) {
result += nom;
continue;
}
if (waiting == 0) {
waiting = nom;
} else {
result += nom + waiting;
waiting = 0;
}
}
if (!result)
printf("NIESTETY\n");
else
printf("%d\n", result);
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <cstdio> #include <algorithm> using namespace std; int nom, n, result, waiting; int main(){ scanf("%d",&n); for(int i = 0; i < n; i++) { scanf("%d",&nom); if ((nom % 2) == 0) { result += nom; continue; } if (waiting == 0) { waiting = nom; } else { result += nom + waiting; waiting = 0; } } if (!result) printf("NIESTETY\n"); else printf("%d\n", result); } |
English