#include "elephants.h"
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define mp make_pair
#define pb push_back
#define MAX_N 1000000
#define MAX_M 1000000
using namespace std;
vi tree[4 * 150000], arr;
int Ltree[4 * 150000], l, n;
int calc(vi pos){
int rez = 0, last = -1;
for(int i = 0; i < (int)pos.size(); i++){
if(pos[i] > last)
{
last = pos[i] + l;
rez++;
}
else
continue;
}
return rez;
}
void build(int node, int l, int r){
if(l == r){
vi nov;
nov.pb(arr[l]);
tree[node] = nov;
Ltree[node] = 1;
}
else{
int mid = (l + r) / 2;
build(node * 2, l, mid);
build(node * 2 + 1, mid + 1, r);
merge(tree[node * 2].begin(), tree[node * 2].end(), tree[node * 2 + 1].begin(), tree[node * 2 + 1].end(), back_inserter(tree[node]));
Ltree[node] = calc(tree[node]);
}
}
void update1(int node, int l, int r, int pos, int val){
if(l == r)
{
tree[node].clear();
tree[node].pb(val);
Ltree[node] = 1;
return ;
}
int mid = (l + r) / 2;
if(pos <= mid)
update1(node * 2, l, mid, pos, val);
else
update1(node * 2 + 1, mid + 1, r, pos, val);
tree[node].clear();
merge(tree[node * 2].begin(), tree[node *2].end(), tree[node * 2 + 1].begin(), tree[node *2 + 1].end(), back_inserter(tree[node]));
Ltree[node] = calc(tree[node]);
}
void init(int N, int L, int X[])
{
n = N;
l = L;
arr.resize(n);
for(int i = 0; i < n; i++){
arr[i] = X[i];
}
build(1, 0, n - 1);
}
int update(int i, int y)
{
update1(1, 0, n - 1, i, y);
return Ltree[1];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
14444 KB |
Output is correct |
2 |
Correct |
11 ms |
14444 KB |
Output is correct |
3 |
Correct |
11 ms |
14444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
14444 KB |
Output is correct |
2 |
Correct |
11 ms |
14444 KB |
Output is correct |
3 |
Correct |
11 ms |
14444 KB |
Output is correct |
4 |
Correct |
11 ms |
14444 KB |
Output is correct |
5 |
Correct |
11 ms |
14444 KB |
Output is correct |
6 |
Correct |
12 ms |
14444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
14444 KB |
Output is correct |
2 |
Correct |
11 ms |
14444 KB |
Output is correct |
3 |
Correct |
11 ms |
14444 KB |
Output is correct |
4 |
Correct |
11 ms |
14444 KB |
Output is correct |
5 |
Correct |
11 ms |
14444 KB |
Output is correct |
6 |
Correct |
12 ms |
14444 KB |
Output is correct |
7 |
Correct |
8019 ms |
17700 KB |
Output is correct |
8 |
Execution timed out |
9101 ms |
19052 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
14444 KB |
Output is correct |
2 |
Correct |
11 ms |
14444 KB |
Output is correct |
3 |
Correct |
11 ms |
14444 KB |
Output is correct |
4 |
Correct |
11 ms |
14444 KB |
Output is correct |
5 |
Correct |
11 ms |
14444 KB |
Output is correct |
6 |
Correct |
12 ms |
14444 KB |
Output is correct |
7 |
Correct |
8019 ms |
17700 KB |
Output is correct |
8 |
Execution timed out |
9101 ms |
19052 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
14444 KB |
Output is correct |
2 |
Correct |
11 ms |
14444 KB |
Output is correct |
3 |
Correct |
11 ms |
14444 KB |
Output is correct |
4 |
Correct |
11 ms |
14444 KB |
Output is correct |
5 |
Correct |
11 ms |
14444 KB |
Output is correct |
6 |
Correct |
12 ms |
14444 KB |
Output is correct |
7 |
Correct |
8019 ms |
17700 KB |
Output is correct |
8 |
Execution timed out |
9101 ms |
19052 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |