#include "weirdtree.h"
#include <bits/stdc++.h>
#define ll long long
#define ii pair<ll,ll>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#ifndef DEBUG
#define cerr if (0) cerr
#endif // DEBUG
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]);
}
cerr<<lb<<' '<<s<<endl;
for (int i=1;i<=n;i++){
cerr<<v[i]<<' ';
}
cerr<<endl;
// 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 |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
3 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
3 ms |
340 KB |
Output is correct |
3 |
Execution timed out |
2079 ms |
2852 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
340 KB |
Output is correct |
2 |
Correct |
3 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
340 KB |
Output is correct |
2 |
Correct |
3 ms |
344 KB |
Output is correct |
3 |
Execution timed out |
2048 ms |
8292 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2025 ms |
7332 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
3 ms |
340 KB |
Output is correct |
3 |
Execution timed out |
2079 ms |
2852 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
3 ms |
340 KB |
Output is correct |
3 |
Execution timed out |
2079 ms |
2852 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |