# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
935152 | kim | Chorus (JOI23_chorus) | C++17 | 7015 ms | 15192 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;
using ll=long long;
using pii=pair<int,int>;
#define f first
#define s second
const ll inf=1e18;
int a[1000005],b[1000005],pos[1000005],pos2[1000005];
ll dp[2][1000005],qs[1000005];
ll f(int L,int R){
int x=pos2[L];
if(x>R) return 0;
return qs[R]-qs[x-1]-L*(R-x+1);
}
void play(int l,int r,int optl,int optr,int z){
if(l>r) return;
int mid=l+r>>1;
pair<ll,int> best(inf,0);
for(int i=optl;i<=min(mid,optr);++i){
best=min(best,{dp[!z][i-1]+f(i,mid),i});
}
dp[z][mid]=best.f;
play(l,mid-1,optl,best.s,z);
play(mid+1,r,best.s,optr,z);
}
Compilation message (stderr)
# | 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... |