Submission #202087

#TimeUsernameProblemLanguageResultExecution timeMemory
202087algorithm16Kas (COCI17_kas)C++14
30 / 100
30 ms3832 KiB
#include<iostream> #include<algorithm> using namespace std; int dp[505][2005],arr[505],sum,n; int rek(int ind,int x,int y) { if(ind==n) { if(x==y) return x; return -1e9; } if(dp[ind][int(x-y+1e3)]!=0) return dp[ind][int(x-y+1e3)]; int ret=max(rek(ind+1,x,y),max(rek(ind+1,x+arr[ind],y),rek(ind+1,x,y+arr[ind]))); dp[ind][int(x-y+1e3)]=ret; return ret; } int main() { cin >> n; for(int i=0;i<n;i++) { cin >> arr[i]; sum+=arr[i]; } int sol=rek(0,0,0); cout << sum-sol; return 0; }
#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...