#include "weirdtree.h"
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000001
#define int long long
int a[300000], n;
#undef int
void initialise(int N, int Q, int h[]) {
n = N;
for(int i = 0; i < n; i++) {
a[i] = h[i+1];
}
}
void cut(int l, int r, int k) {
l--; r--;
int L = 0, R = INF, M, cnt = 0;
for(int i = l; i <= r; i++) cnt += a[i];
if(k >= cnt) {
for(int i = l; i <= r; i++) a[i] = 0;
return;
}
while(L < R) {
M = (L+R)/2;
cnt = 0;
for(int i = l; i <= r; i++) cnt += max(a[i]-M, 0LL);
if(cnt < k) R = M;
else L = M+1;
}
cnt = 0;
for(int i = l; i <= r; i++) cnt += max(a[i]-L, 0LL);
cnt = k-cnt;
for(int i = l; i <= r; i++) {
if(a[i] >= L) {
a[i] = L;
if(cnt) {
a[i]--;
cnt--;
}
}
}
}
void magic(int i, int x) {
i--;
a[i] = x;
}
long long int inspect(int l, int r) {
l--; r--;
long long ans = 0;
for(int i = l; i <= r; i++) ans += a[i];
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2025 ms |
3648 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |