#include<bits/stdc++.h>
#define rep(i,k,n) for(int i= (int) k;i< (int) n;i++)
#define pb push_back
#define ft first
#define sd second
typedef long long ll;
const long long inf = 9223372036854775807ll;
const int iinf = 2147483647;
const int limit = 1048576;
using namespace std;
bool sync_with_stdio (bool sync = false);
namespace patch
{
template < typename T > std::string to_string( const T& n )
{
std::ostringstream stm ;
stm << n ;
return stm.str() ;
}
}
int main(){
ll n, min_odd = inf, s = 0, t1; scanf("%lld", &n);
rep(i, 0, n)
{
scanf("%lld", &t1);
s += t1;
if(t1 % 2)
min_odd = min(min_odd, t1);
}
if(s % 2)
{
if(n == 1)
printf("NIESTETY\n");
else
printf("%lld\n", s - min_odd);
}
else
printf("%lld\n", s);
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 | #include<bits/stdc++.h> #define rep(i,k,n) for(int i= (int) k;i< (int) n;i++) #define pb push_back #define ft first #define sd second typedef long long ll; const long long inf = 9223372036854775807ll; const int iinf = 2147483647; const int limit = 1048576; using namespace std; bool sync_with_stdio (bool sync = false); namespace patch { template < typename T > std::string to_string( const T& n ) { std::ostringstream stm ; stm << n ; return stm.str() ; } } int main(){ ll n, min_odd = inf, s = 0, t1; scanf("%lld", &n); rep(i, 0, n) { scanf("%lld", &t1); s += t1; if(t1 % 2) min_odd = min(min_odd, t1); } if(s % 2) { if(n == 1) printf("NIESTETY\n"); else printf("%lld\n", s - min_odd); } else printf("%lld\n", s); return 0; } |
English