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 pb push_back
using namespace std;
const int NN=3e5+5;
ll n,a[NN];
void initialise(int N, int Q, int h[]) {
n=N;
for (int i=1;i<=n;i++) a[i]=h[i];
return;
}
void cut(int l, int r, int kk) {
ll k=kk;
while (k>0){
ll mx1=0,mx2=0,f=0,d=0;
vector<int> v;
for (int i=l;i<=r;i++) mx1=max(mx1,a[i]);
if (mx1==0) break;
for (int i=l;i<=r;i++){
if (a[i]==mx1){
v.pb(i);
f++;
}
else mx2=max(mx2,a[i]);
}
//cout<<mx1<<' '<<mx2<<endl;
d=(mx1-mx2);
if (k>=d*f){
for (auto u:v) a[u]=mx2;
k-=d*f;
continue;
}
for (auto u:v) a[u]-=k/f;
for (int i=0;i<k%f;i++) a[v[i]]--;
break;
}return;
}
void magic(int i, int x) {
a[i]=x;
return;
}
long long int inspect(int l, int r) {
ll sum=0;
for (int i=l;i<=r;i++) sum+=a[i];
return sum;
}
# | 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... |