#include <stdio.h> #include <time.h> #include <math.h> #include <stdlib.h> #include <string.h> #include <map> #include <string> #include <vector> #include <iostream> #include <sstream> #include <queue> #include <algorithm> using namespace std; #define ll long long #define PB push_back #define FOR(a,start,end) for(ll a=ll(start); a<ll(end); a++) #define INF INT_MAX #define SORT(a) sort(a.begin(),a.end()) #define CL(a,x) memset(a,x,sizeof(a)) #define REP(a,x) for(ll a=0;a<x;a++) #define REP1(a,x) for(ll a=1;a<=x;a++) #define MP make_pair typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<string> vs; typedef vector<pii> vii; typedef vector<vector<int> > vvi; typedef vector<vector<string> > vvs; typedef vector<pair<string,string> > vss; typedef pair<string,string> pss; typedef pair<int,pii> ppii; typedef vector<ppii> vppii; typedef vector<vector<pii> > vvii; typedef vector<vvi> vvvi; int z,i,j,k,n,a,b; int main() { //freopen( "c:\\wojtek\\uva\\pa\\debug\\t1.in", "rt", stdin); //pi=2*acos(0.0); cin>>n; b=1001; k=0; for(i=0;i<n;i++){ cin>>a; k+=a; if(a%2==1){ b=min(b,a); } } if(k%2==0) cout<<k<<endl; else { k-=b; if(k>0) cout<<k<<endl; else cout<<"NIESTETY"<<endl; } 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 | #include <stdio.h> #include <time.h> #include <math.h> #include <stdlib.h> #include <string.h> #include <map> #include <string> #include <vector> #include <iostream> #include <sstream> #include <queue> #include <algorithm> using namespace std; #define ll long long #define PB push_back #define FOR(a,start,end) for(ll a=ll(start); a<ll(end); a++) #define INF INT_MAX #define SORT(a) sort(a.begin(),a.end()) #define CL(a,x) memset(a,x,sizeof(a)) #define REP(a,x) for(ll a=0;a<x;a++) #define REP1(a,x) for(ll a=1;a<=x;a++) #define MP make_pair typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<string> vs; typedef vector<pii> vii; typedef vector<vector<int> > vvi; typedef vector<vector<string> > vvs; typedef vector<pair<string,string> > vss; typedef pair<string,string> pss; typedef pair<int,pii> ppii; typedef vector<ppii> vppii; typedef vector<vector<pii> > vvii; typedef vector<vvi> vvvi; int z,i,j,k,n,a,b; int main() { //freopen( "c:\\wojtek\\uva\\pa\\debug\\t1.in", "rt", stdin); //pi=2*acos(0.0); cin>>n; b=1001; k=0; for(i=0;i<n;i++){ cin>>a; k+=a; if(a%2==1){ b=min(b,a); } } if(k%2==0) cout<<k<<endl; else { k-=b; if(k>0) cout<<k<<endl; else cout<<"NIESTETY"<<endl; } return 0; } |