#include "weirdtree.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 300'009, SEGSZ = 1<<20;
const int MAXSZ = 1015571557;
ll H[MAXN];
int n;
void initialise(int N, int Q, int h[]) {
int i;
n = N;
for(i=1; i<=n; i++)
H[i] = h[i];
}
void cut(int l, int r, int k) {
int lo = 0, hi = MAXSZ, mid;
while(lo < hi){
mid = (lo+hi+1)/2;
ll temp = 0;
for(int i=l; i<=r; i++)
temp += max(H[i] - mid, 0ll);
if(temp >= k)
lo = mid;
else
hi = mid-1;
}
ll temp = 0;
for(int i=l; i<=r; i++)
temp += max(H[i] - lo, 0ll);
//printf("lo=%d temp=%lld\n", lo, temp);
temp -= k;
if(temp < 0)
temp = 0;
for(int i=r; i>=l; i--){
if(H[i] > lo){
H[i] = lo;
if(temp > 0){
temp--;
H[i]++;
}
}
}
}
void magic(int i, int x) {
H[i] = x;
}
long long int inspect(int l, int r) {
ll ans = 0;
for(int i=l; i<=r; i++)
ans += H[i];
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
348 KB |
Output is correct |
3 |
Execution timed out |
2052 ms |
2456 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
344 KB |
Output is correct |
2 |
Correct |
4 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
344 KB |
Output is correct |
2 |
Correct |
4 ms |
348 KB |
Output is correct |
3 |
Execution timed out |
2072 ms |
7008 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2052 ms |
6604 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
348 KB |
Output is correct |
3 |
Execution timed out |
2052 ms |
2456 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
348 KB |
Output is correct |
3 |
Execution timed out |
2052 ms |
2456 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |