# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
789216 | irmuun | Raisins (IOI09_raisins) | C++17 | 639 ms | 26548 KiB |
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<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
const ll INF=1e18;
ll mn[51][51][51][51],a[51][51],sum[51][51];
void solve(ll l1,ll l2,ll r1,ll r2){
if(mn[l1][l2][r1][r2]<INF) return;
if(l1==l2&&r1==r2){
mn[l1][l2][r1][r2]=0;
return;
}
for(ll i=l1;i<l2;i++){
solve(l1,i,r1,r2);
solve(i+1,l2,r1,r2);
mn[l1][l2][r1][r2]=min(mn[l1][l2][r1][r2],mn[l1][i][r1][r2]+mn[i+1][l2][r1][r2]+sum[l2][r2]-sum[l1-1][r2]-sum[l2][r1-1]+sum[l1-1][r1-1]);
}
for(ll i=r1;i<r2;i++){
solve(l1,l2,r1,i);
solve(l1,l2,i+1,r2);
mn[l1][l2][r1][r2]=min(mn[l1][l2][r1][r2],mn[l1][l2][r1][i]+mn[l1][l2][i+1][r2]+sum[l2][r2]-sum[l1-1][r2]-sum[l2][r1-1]+sum[l1-1][r1-1]);
}
return;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |