Submission #839084

#TimeUsernameProblemLanguageResultExecution timeMemory
839084carot15Kas (COCI17_kas)C++14
30 / 100
71 ms2140 KiB
// carot15 #include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define all(x) begin(x), end(x) #define mp make_pair #define cyd {cout<<"Yes";return;} #define cyn {cout<<"No";return;} const ll nmax=5e6+5; const ll mod=1e9+7; const int X[]={0,0,1,-1}; const int Y[]={-1,1,0,0}; bitset<nmax> bit; int n,a[505],t=0; void solve(){ cin>>n; bit[0]=1; for (int i=1;i<=n;i++){ cin>>a[i]; t+=a[i]; bit|=bit<<a[i]; } ll ans=t; for (int i=1;i<=t/2;i++){ if (bit[i]){ ll p=t-i*2; if (bit[p]) ans=p; } } cout<<ans+(t-ans)/2; } /* z t-z */ int main(){ ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); // freopen(".INP", "r", stdin); // freopen(".OUT", "w", stdout); int T=1; // cin>>T; while(T--){ solve(); cout<<'\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...