This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |