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 "weirdtree.h"
#include <bits/stdc++.h>
#define ll long long
#define ii pair<ll,ll>
#define cerr if (0) cerr
using namespace std;
ll n;
vector<ll> v;
void initialise(int N, int Q, int H[]) {
// Your code here.
n=N;
v.emplace_back(0);
for (int i=1;i<=N;i++){
v.emplace_back(H[i]);
}
}
void cut(int l, int r, int k) {
ll lb=0,rb=1000000000,mb;
while (lb!=rb-1){
mb=(lb+rb)>>1;
ll ans=0;
for (int i=l;i<=r;i++){
ans+=max(v[i]-mb,0LL);
}
if (ans>=k) lb=mb;
else rb=mb;
}
ll s=l,e=r+2,m;
while (s!=e-1){
m=(s+e)>>1;
ll ans=0;
for (int i=l;i<m;i++){
ans+=max(v[i]-lb,0LL);
}
for (int i=m;i<=r;i++){
ans+=max(v[i]-lb-1,0LL);
}
if (ans>k) e=m;
else s=m;
}
for (int i=l;i<s;i++){
v[i]=min(lb,v[i]);
}
for (int i=s;i<=r;i++){
v[i]=min(lb+1,v[i]);
}
// Your code here.
}
void magic(int i, int x) {
v[i]=x;
// Your code here.
}
long long int inspect(int l, int r) {
// Your code here.
ll ans=0;
for (int i=l;i<=r;i++){
ans+=v[i];
}
return ans;
}
# | 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... |