# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
953475 | owoovo | Chorus (JOI23_chorus) | C++17 | 4663 ms | 47500 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>
#define ll long long
#define F first
#define S second
using namespace std;
const ll maxn=1e18;
ll n,k,bto[1000010],bhh[1000010],hhsum[1000010];
pair<ll,ll> dp[1000010];
ll cost(ll i,ll j){
if(i>=j)return maxn;
ll l=max(i,bto[i]),r=j;
return hhsum[r]-hhsum[l]-i*(r-l);
}
struct seg{
ll pos,l,r;
seg(ll _pos,ll _l,ll _r){
pos=_pos,l=_l,r=_r;
}
};
bool check(ll d){
for(int i=1;i<=n;i++)dp[i]={maxn,0};
deque<seg> sg;
sg.push_back({0,1,n});
for(int i=1;i<=n;i++){
while(sg.front().r<i)sg.pop_front();
ll pos=sg.front().pos;
dp[i]={dp[pos].F+cost(pos,i)+d,dp[pos].S+1};
while(!sg.empty()&&dp[i].F+cost(i,sg.back().l)<dp[sg.back().pos].F+cost(sg.back().pos,sg.back().l)){
sg.pop_back();
}
# | 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... |