#include "weirdtree.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> lst;
priority_queue<int> pq;
void initialise(int N, int Q, int h[]) {
lst.push_back(0);
for(int i = 1; i <= N; i++){
lst.push_back(h[i]);
}
}
void cut(int l, int r, int k) {
while(!pq.empty()){
pq.pop();
}
for(int i = l; i <= r; i++){
pq.push(lst[i]);
}
pq.push(0);
int num = 0;
int v = 0;
while(!pq.empty() && k >= (v - pq.top()) * (long long int)num ){
k = k - (v - pq.top()) * num;
num++;
v = pq.top();
pq.pop();
}
if(pq.empty()){
for(int i = l; i <= r; i++){
lst[i] = 0;
}
return;
}
int unnuse = k % num;
int nam = k / num;
v = v - nam;
for(int i = l; i <= r; i++){
if(lst[i] >= v){
if(unnuse >= 1){
lst[i] = v - 1;
unnuse--;
}
else{
lst[i] = v;
}
}
}
/*for(int i = 0; i < lst.size(); i++){
printf("%d ",lst[i]);
}
printf("\n");*/
}
void magic(int i, int x) {
lst[i] = x;
}
long long int inspect(int l, int r) {
long long int V = 0;
for(int i = l; i <= r; i++){
V = V + lst[i];
}
return V;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
340 KB |
Output is correct |
2 |
Correct |
9 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
340 KB |
Output is correct |
2 |
Correct |
9 ms |
340 KB |
Output is correct |
3 |
Execution timed out |
2081 ms |
1736 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
340 KB |
Output is correct |
2 |
Correct |
9 ms |
388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
340 KB |
Output is correct |
2 |
Correct |
9 ms |
388 KB |
Output is correct |
3 |
Execution timed out |
2025 ms |
7088 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2069 ms |
5580 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
340 KB |
Output is correct |
2 |
Correct |
9 ms |
340 KB |
Output is correct |
3 |
Execution timed out |
2081 ms |
1736 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
340 KB |
Output is correct |
2 |
Correct |
9 ms |
340 KB |
Output is correct |
3 |
Execution timed out |
2081 ms |
1736 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |