#include <iostream>
#include <string>
#include <cctype>
#define SIZE_OF_ARRAY(x) (sizeof(x) / sizeof(*(x)))
typedef unsigned int uint;
static char get_char_buffer[4 * 1024];
static std::size_t get_char_buffer_i = SIZE_OF_ARRAY(get_char_buffer);
static std::size_t get_char_buffer_n = SIZE_OF_ARRAY(get_char_buffer);
static char get_char_prefix = 0;
static char get_char_result = 0;
int get_char()
{
get_char_result = 0;
if (get_char_prefix)
{
get_char_result = get_char_prefix;
get_char_prefix = 0;
}
else if (get_char_buffer_n == 0)
{
get_char_result = std::char_traits<char>::eof();
}
else if (get_char_buffer_i < get_char_buffer_n)
{
get_char_result = get_char_buffer[get_char_buffer_i++];
}
else
{
std::cin.read(get_char_buffer, SIZE_OF_ARRAY(get_char_buffer));
get_char_buffer_i = 0;
get_char_buffer_n = std::cin.gcount();
return get_char();
}
return get_char_result;
}
void unget_char()
{
get_char_prefix = get_char_result;
}
uint get_uint()
{
int c;
while (isspace(c = get_char()));
uint value = (c - '0');
while (isdigit(c = get_char()))
{
value = (10 * value) + (c - '0');
}
return value;
}
int main()
{
std::ios_base::sync_with_stdio(false);
std::cin.tie(0);
uint n = get_uint();
uint sum = 0;
uint count_odd = 0;
uint min_odd = 1001;
for (uint i = 0; i < n; ++i)
{
uint a = get_uint();
sum += a;
if (a % 2)
{
++count_odd;
if (a < min_odd)
{
min_odd = a;
}
}
}
uint result = sum;
if (count_odd % 2)
{
result -= min_odd;
}
if (result)
{
std::cout << result << '\n';
}
else
{
std::cout << "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 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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | #include <iostream> #include <string> #include <cctype> #define SIZE_OF_ARRAY(x) (sizeof(x) / sizeof(*(x))) typedef unsigned int uint; static char get_char_buffer[4 * 1024]; static std::size_t get_char_buffer_i = SIZE_OF_ARRAY(get_char_buffer); static std::size_t get_char_buffer_n = SIZE_OF_ARRAY(get_char_buffer); static char get_char_prefix = 0; static char get_char_result = 0; int get_char() { get_char_result = 0; if (get_char_prefix) { get_char_result = get_char_prefix; get_char_prefix = 0; } else if (get_char_buffer_n == 0) { get_char_result = std::char_traits<char>::eof(); } else if (get_char_buffer_i < get_char_buffer_n) { get_char_result = get_char_buffer[get_char_buffer_i++]; } else { std::cin.read(get_char_buffer, SIZE_OF_ARRAY(get_char_buffer)); get_char_buffer_i = 0; get_char_buffer_n = std::cin.gcount(); return get_char(); } return get_char_result; } void unget_char() { get_char_prefix = get_char_result; } uint get_uint() { int c; while (isspace(c = get_char())); uint value = (c - '0'); while (isdigit(c = get_char())) { value = (10 * value) + (c - '0'); } return value; } int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(0); uint n = get_uint(); uint sum = 0; uint count_odd = 0; uint min_odd = 1001; for (uint i = 0; i < n; ++i) { uint a = get_uint(); sum += a; if (a % 2) { ++count_odd; if (a < min_odd) { min_odd = a; } } } uint result = sum; if (count_odd % 2) { result -= min_odd; } if (result) { std::cout << result << '\n'; } else { std::cout << "NIESTETY\n"; } return 0; } |
English