#include "weirdtree.h"
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define dbg(...) printf(__VA_ARGS__);
#else
#define dbg(...)
#endif
#define sf scanf
#define pf printf
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define INF 1023456789
typedef long long ll;
typedef pair<int,int> ii;
#define maxn 300005
int n,q,h[maxn];
void initialise(int N,int Q,int H[]){
n=N,q=Q;
for(int i=1;i<=n;++i)h[i]=H[i];
}
void cut(int l,int r,int k){
if(n<=1000&&q<=1000){
vector<int> v;
for(int i=l;i<=r;++i)v.pb(h[i]);
v.pb(0);
sort(all(v));
int num=0,mn=v.back(),rem=k;
while(!v.empty()){
int x=v.back();
if((ll)num*(mn-x)<=rem){
rem-=num*(mn-x);
++num;
mn=x;
v.pop_back();
}
else{
int sub=rem/num;
mn-=sub;
rem-=sub*num;
break;
}
}
int cnt=0;
for(int i=l;i<=r;++i){
if(h[i]>=mn){
if(cnt<rem)h[i]=mn-1;
else h[i]=mn;
++cnt;
}
h[i]=max(h[i],0);
}
}
}
void magic(int i,int x){
if(n<=1000&&q<=1000){
h[i]=x;
}
}
ll inspect(int l,int r){
if(n<=1000&&q<=1000){
ll ans=0;
for(int i=l;i<=r;++i)ans+=h[i];
return ans;
}
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
340 KB |
Output is correct |
2 |
Correct |
5 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
340 KB |
Output is correct |
2 |
Correct |
5 ms |
340 KB |
Output is correct |
3 |
Incorrect |
6 ms |
3036 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
340 KB |
Output is correct |
2 |
Correct |
3 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
340 KB |
Output is correct |
2 |
Correct |
3 ms |
468 KB |
Output is correct |
3 |
Incorrect |
23 ms |
10544 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
9536 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
340 KB |
Output is correct |
2 |
Correct |
5 ms |
340 KB |
Output is correct |
3 |
Incorrect |
6 ms |
3036 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
340 KB |
Output is correct |
2 |
Correct |
5 ms |
340 KB |
Output is correct |
3 |
Incorrect |
6 ms |
3036 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |