// 1bkie.cpp : Defines the entry point for the console application.
//
#include <cstdio>
using namespace std;
int main()
{
const long long MAX_MONEY = 1000;
//n (1 <= n <= 1 000 000)
long n;
scanf("%ld",&n);
long total = 0;
long worstodd = MAX_MONEY+1;
long countodd = 0;
//a1, a2, . . . , an (1 <= ai <= 1000)
long amoney = 0;
for(long i=0; i < n; i++)
{
scanf("%ld",&amoney);
if((amoney&1)==0)
{ //even
total += amoney;
continue;
}
//odd
countodd++;
worstodd = amoney < worstodd ? amoney : worstodd;
total += amoney;
}
if(1== (countodd & 1))
{
total -= worstodd;
}
if(total==0)
printf("NIESTETY");
else
printf("%ld",total);
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 | // 1bkie.cpp : Defines the entry point for the console application. // #include <cstdio> using namespace std; int main() { const long long MAX_MONEY = 1000; //n (1 <= n <= 1 000 000) long n; scanf("%ld",&n); long total = 0; long worstodd = MAX_MONEY+1; long countodd = 0; //a1, a2, . . . , an (1 <= ai <= 1000) long amoney = 0; for(long i=0; i < n; i++) { scanf("%ld",&amoney); if((amoney&1)==0) { //even total += amoney; continue; } //odd countodd++; worstodd = amoney < worstodd ? amoney : worstodd; total += amoney; } if(1== (countodd & 1)) { total -= worstodd; } if(total==0) printf("NIESTETY"); else printf("%ld",total); return 0; } |
English