#include "bubblesort2.h"
#include <bits/stdc++.h>
#define pii pair<int, int>
#define x first
#define y second
using namespace std;
#define var int p = 1, int l = 0, int r = coord.size() - 1
#define mid ((l + r) >> 1)
#define lb p << 1, l, mid
#define rb p << 1 | 1, mid + 1, r
const int N = 1 << 19;
int n, q;
int t[N << 1], lz[N << 1];
vector<pii> coord;
int get(pii x) { return lower_bound(coord.begin(), coord.end(), x) - coord.begin(); }
void push(var) {
if(lz[p]) {
t[p] += lz[p];
if(l != r) lz[p << 1] += lz[p], lz[p << 1 | 1] += lz[p];
lz[p] = 0;
}
}
void update(int x, int y, int k, var) {
push(p, l, r);
if(x > r || l > y) return;
if(x <= l && r <= y) {
lz[p] += k, push(p, l, r);
return;
}
update(x, y, k, lb), update(x, y, k, rb);
t[p] = max(t[p << 1], t[p << 1 | 1]);
}
vector<int> countScans(vector<int> A, vector<int> X, vector<int> V) {
n = A.size(), q = X.size();
for(int i = 0; i < n; i++) coord.emplace_back(A[i], i);
for(int i = 0; i < q; i++) coord.emplace_back(V[i], X[i]);
sort(coord.begin(), coord.end());
coord.resize(unique(coord.begin(), coord.end()) - coord.begin());
function<void(int, int)> add = [&](int i, int coef) {
int idx1 = get(pii(A[i], i));
update(idx1, idx1, (i + 1) * coef);
int idx2 = get(pii(A[i], -1));
update(idx2, coord.size() - 1, -coef);
};
vector<int> ans;
for(int i = 0; i < n; i++) add(i, 1);
for(int i = 0; i < q; i++) {
add(X[i], -1);
A[X[i]] = V[i];
add(X[i], 1);
ans.emplace_back(t[1]);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
7 ms |
512 KB |
Output is correct |
3 |
Correct |
10 ms |
640 KB |
Output is correct |
4 |
Correct |
10 ms |
512 KB |
Output is correct |
5 |
Correct |
10 ms |
512 KB |
Output is correct |
6 |
Correct |
10 ms |
640 KB |
Output is correct |
7 |
Correct |
10 ms |
512 KB |
Output is correct |
8 |
Correct |
10 ms |
512 KB |
Output is correct |
9 |
Correct |
11 ms |
512 KB |
Output is correct |
10 |
Correct |
9 ms |
512 KB |
Output is correct |
11 |
Correct |
11 ms |
512 KB |
Output is correct |
12 |
Correct |
10 ms |
640 KB |
Output is correct |
13 |
Correct |
9 ms |
512 KB |
Output is correct |
14 |
Correct |
9 ms |
512 KB |
Output is correct |
15 |
Correct |
10 ms |
640 KB |
Output is correct |
16 |
Correct |
9 ms |
384 KB |
Output is correct |
17 |
Correct |
10 ms |
512 KB |
Output is correct |
18 |
Correct |
9 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
7 ms |
512 KB |
Output is correct |
3 |
Correct |
10 ms |
640 KB |
Output is correct |
4 |
Correct |
10 ms |
512 KB |
Output is correct |
5 |
Correct |
10 ms |
512 KB |
Output is correct |
6 |
Correct |
10 ms |
640 KB |
Output is correct |
7 |
Correct |
10 ms |
512 KB |
Output is correct |
8 |
Correct |
10 ms |
512 KB |
Output is correct |
9 |
Correct |
11 ms |
512 KB |
Output is correct |
10 |
Correct |
9 ms |
512 KB |
Output is correct |
11 |
Correct |
11 ms |
512 KB |
Output is correct |
12 |
Correct |
10 ms |
640 KB |
Output is correct |
13 |
Correct |
9 ms |
512 KB |
Output is correct |
14 |
Correct |
9 ms |
512 KB |
Output is correct |
15 |
Correct |
10 ms |
640 KB |
Output is correct |
16 |
Correct |
9 ms |
384 KB |
Output is correct |
17 |
Correct |
10 ms |
512 KB |
Output is correct |
18 |
Correct |
9 ms |
512 KB |
Output is correct |
19 |
Correct |
26 ms |
1272 KB |
Output is correct |
20 |
Correct |
29 ms |
1280 KB |
Output is correct |
21 |
Correct |
27 ms |
1280 KB |
Output is correct |
22 |
Correct |
28 ms |
1280 KB |
Output is correct |
23 |
Correct |
27 ms |
1280 KB |
Output is correct |
24 |
Correct |
26 ms |
1280 KB |
Output is correct |
25 |
Correct |
26 ms |
1280 KB |
Output is correct |
26 |
Correct |
26 ms |
1280 KB |
Output is correct |
27 |
Correct |
25 ms |
1280 KB |
Output is correct |
28 |
Correct |
25 ms |
1280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
1532 KB |
Output is correct |
2 |
Correct |
107 ms |
3316 KB |
Output is correct |
3 |
Correct |
185 ms |
5376 KB |
Output is correct |
4 |
Correct |
182 ms |
5484 KB |
Output is correct |
5 |
Correct |
179 ms |
5356 KB |
Output is correct |
6 |
Correct |
174 ms |
5484 KB |
Output is correct |
7 |
Correct |
206 ms |
5520 KB |
Output is correct |
8 |
Correct |
179 ms |
5356 KB |
Output is correct |
9 |
Correct |
169 ms |
5356 KB |
Output is correct |
10 |
Correct |
149 ms |
4460 KB |
Output is correct |
11 |
Correct |
139 ms |
4460 KB |
Output is correct |
12 |
Correct |
132 ms |
4460 KB |
Output is correct |
13 |
Correct |
139 ms |
4460 KB |
Output is correct |
14 |
Correct |
139 ms |
4460 KB |
Output is correct |
15 |
Correct |
135 ms |
4460 KB |
Output is correct |
16 |
Correct |
136 ms |
4460 KB |
Output is correct |
17 |
Correct |
137 ms |
4460 KB |
Output is correct |
18 |
Correct |
143 ms |
4612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
7 ms |
512 KB |
Output is correct |
3 |
Correct |
10 ms |
640 KB |
Output is correct |
4 |
Correct |
10 ms |
512 KB |
Output is correct |
5 |
Correct |
10 ms |
512 KB |
Output is correct |
6 |
Correct |
10 ms |
640 KB |
Output is correct |
7 |
Correct |
10 ms |
512 KB |
Output is correct |
8 |
Correct |
10 ms |
512 KB |
Output is correct |
9 |
Correct |
11 ms |
512 KB |
Output is correct |
10 |
Correct |
9 ms |
512 KB |
Output is correct |
11 |
Correct |
11 ms |
512 KB |
Output is correct |
12 |
Correct |
10 ms |
640 KB |
Output is correct |
13 |
Correct |
9 ms |
512 KB |
Output is correct |
14 |
Correct |
9 ms |
512 KB |
Output is correct |
15 |
Correct |
10 ms |
640 KB |
Output is correct |
16 |
Correct |
9 ms |
384 KB |
Output is correct |
17 |
Correct |
10 ms |
512 KB |
Output is correct |
18 |
Correct |
9 ms |
512 KB |
Output is correct |
19 |
Correct |
26 ms |
1272 KB |
Output is correct |
20 |
Correct |
29 ms |
1280 KB |
Output is correct |
21 |
Correct |
27 ms |
1280 KB |
Output is correct |
22 |
Correct |
28 ms |
1280 KB |
Output is correct |
23 |
Correct |
27 ms |
1280 KB |
Output is correct |
24 |
Correct |
26 ms |
1280 KB |
Output is correct |
25 |
Correct |
26 ms |
1280 KB |
Output is correct |
26 |
Correct |
26 ms |
1280 KB |
Output is correct |
27 |
Correct |
25 ms |
1280 KB |
Output is correct |
28 |
Correct |
25 ms |
1280 KB |
Output is correct |
29 |
Correct |
36 ms |
1532 KB |
Output is correct |
30 |
Correct |
107 ms |
3316 KB |
Output is correct |
31 |
Correct |
185 ms |
5376 KB |
Output is correct |
32 |
Correct |
182 ms |
5484 KB |
Output is correct |
33 |
Correct |
179 ms |
5356 KB |
Output is correct |
34 |
Correct |
174 ms |
5484 KB |
Output is correct |
35 |
Correct |
206 ms |
5520 KB |
Output is correct |
36 |
Correct |
179 ms |
5356 KB |
Output is correct |
37 |
Correct |
169 ms |
5356 KB |
Output is correct |
38 |
Correct |
149 ms |
4460 KB |
Output is correct |
39 |
Correct |
139 ms |
4460 KB |
Output is correct |
40 |
Correct |
132 ms |
4460 KB |
Output is correct |
41 |
Correct |
139 ms |
4460 KB |
Output is correct |
42 |
Correct |
139 ms |
4460 KB |
Output is correct |
43 |
Correct |
135 ms |
4460 KB |
Output is correct |
44 |
Correct |
136 ms |
4460 KB |
Output is correct |
45 |
Correct |
137 ms |
4460 KB |
Output is correct |
46 |
Correct |
143 ms |
4612 KB |
Output is correct |
47 |
Correct |
677 ms |
19808 KB |
Output is correct |
48 |
Runtime error |
424 ms |
49364 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
49 |
Halted |
0 ms |
0 KB |
- |