#include <cstdio> #define BUF_SIZE 4000 char bufor[BUF_SIZE + 1 + 30]; char *buf_pointer; char *end_pointer; bool end_of_buffer() { return buf_pointer == end_pointer; } void init() { buf_pointer = bufor; int readed = fread(bufor, 1, BUF_SIZE, stdin); end_pointer = bufor + readed; if (readed) { --end_pointer; //read last number to end while ((*end_pointer & 16) && readed) { ++end_pointer; readed = fread(end_pointer, 1, 1, stdin); } if (*end_pointer & 16) { ++end_pointer; *end_pointer = ' '; } //read white spaces for (; (*buf_pointer & 16) == false;) { ++buf_pointer; if (buf_pointer >= end_pointer) { init(); } } } } void read_int(unsigned& l) { char *data = buf_pointer; if (end_of_buffer()) return; l = 0; while (*data & 16) { l *= 10; l += *data & 15; //-40 ++data; } //read white spaces for (; (*data & 16) == false;) { ++data; if (data >= end_pointer) { init(); data = buf_pointer; } } buf_pointer = data; } int main() { init(); unsigned n, t, r = 0, m = 1001; //scanf("%d", &n); read_int(n); while(n--) { //scanf("%d", &t); read_int(t); t % 2 && t < m ? m = t : 0; r += t; } if (r % 2) r -= m; r ? printf("%u\n", r) : puts("NIESTETY"); 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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | #include <cstdio> #define BUF_SIZE 4000 char bufor[BUF_SIZE + 1 + 30]; char *buf_pointer; char *end_pointer; bool end_of_buffer() { return buf_pointer == end_pointer; } void init() { buf_pointer = bufor; int readed = fread(bufor, 1, BUF_SIZE, stdin); end_pointer = bufor + readed; if (readed) { --end_pointer; //read last number to end while ((*end_pointer & 16) && readed) { ++end_pointer; readed = fread(end_pointer, 1, 1, stdin); } if (*end_pointer & 16) { ++end_pointer; *end_pointer = ' '; } //read white spaces for (; (*buf_pointer & 16) == false;) { ++buf_pointer; if (buf_pointer >= end_pointer) { init(); } } } } void read_int(unsigned& l) { char *data = buf_pointer; if (end_of_buffer()) return; l = 0; while (*data & 16) { l *= 10; l += *data & 15; //-40 ++data; } //read white spaces for (; (*data & 16) == false;) { ++data; if (data >= end_pointer) { init(); data = buf_pointer; } } buf_pointer = data; } int main() { init(); unsigned n, t, r = 0, m = 1001; //scanf("%d", &n); read_int(n); while(n--) { //scanf("%d", &t); read_int(t); t % 2 && t < m ? m = t : 0; r += t; } if (r % 2) r -= m; r ? printf("%u\n", r) : puts("NIESTETY"); return 0; } |