// by me
#include "bubblesort2.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define all(x) x.begin(), x.end()
std::vector<int> countScans(std::vector<int> A, std::vector<int> X, std::vector<int> V){
int Q = X.size();
int N = A.size();
vector<int> ans(Q, 0);
if(N <= 8000){
for(int i = 0; i < Q; i++){
A[X[i]] = V[i];
vector<int> f(N);
iota(all(f), 0);
sort(all(f), [&](int a, int b){
return A[a] < A[b];
});
for(int j = 0; j < N; j++){
ans[i] = max(ans[i], f[j] - j);
}
}
return ans;
}
vector<set<int>> f(101);
for(int i = 0; i < N; i++){
f[A[i]].insert(i);
}
for(int i = 0; i < Q; i++){
f[A[X[i]]].erase(X[i]);
A[X[i]] = V[i];
f[A[X[i]]].insert(X[i]);
int x = 0;
for(auto &st : f){
if(st.empty()) continue;
x += st.size();
int mx = *st.rbegin();
ans[i] = max(ans[i], mx - x + 1);
}
}
return ans;
}
//
/*
int readInt(){
int i;
if(scanf("%d",&i)!=1){
fprintf(stderr,"Error while reading input\n");
exit(1);
}
return i;
}
int main(){
int N,Q;
N=readInt();
Q=readInt();
std::vector<int> A(N);
for(int i=0;i<N;i++)
A[i]=readInt();
std::vector<int> X(Q),V(Q);
for(int j=0;j<Q;j++){
X[j]=readInt();
V[j]=readInt();
}
std::vector<int> res=countScans(A,X,V);
for(int j=0;j<int(res.size());j++)
printf("%d\n",res[j]);
}
//*/
// by me
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
348 KB |
Output is correct |
2 |
Correct |
28 ms |
348 KB |
Output is correct |
3 |
Correct |
199 ms |
472 KB |
Output is correct |
4 |
Correct |
198 ms |
348 KB |
Output is correct |
5 |
Correct |
189 ms |
344 KB |
Output is correct |
6 |
Correct |
116 ms |
344 KB |
Output is correct |
7 |
Correct |
155 ms |
348 KB |
Output is correct |
8 |
Correct |
181 ms |
468 KB |
Output is correct |
9 |
Correct |
198 ms |
468 KB |
Output is correct |
10 |
Correct |
104 ms |
472 KB |
Output is correct |
11 |
Correct |
101 ms |
348 KB |
Output is correct |
12 |
Correct |
103 ms |
472 KB |
Output is correct |
13 |
Correct |
101 ms |
344 KB |
Output is correct |
14 |
Correct |
102 ms |
472 KB |
Output is correct |
15 |
Correct |
107 ms |
472 KB |
Output is correct |
16 |
Correct |
86 ms |
344 KB |
Output is correct |
17 |
Correct |
88 ms |
472 KB |
Output is correct |
18 |
Correct |
81 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
348 KB |
Output is correct |
2 |
Correct |
28 ms |
348 KB |
Output is correct |
3 |
Correct |
199 ms |
472 KB |
Output is correct |
4 |
Correct |
198 ms |
348 KB |
Output is correct |
5 |
Correct |
189 ms |
344 KB |
Output is correct |
6 |
Correct |
116 ms |
344 KB |
Output is correct |
7 |
Correct |
155 ms |
348 KB |
Output is correct |
8 |
Correct |
181 ms |
468 KB |
Output is correct |
9 |
Correct |
198 ms |
468 KB |
Output is correct |
10 |
Correct |
104 ms |
472 KB |
Output is correct |
11 |
Correct |
101 ms |
348 KB |
Output is correct |
12 |
Correct |
103 ms |
472 KB |
Output is correct |
13 |
Correct |
101 ms |
344 KB |
Output is correct |
14 |
Correct |
102 ms |
472 KB |
Output is correct |
15 |
Correct |
107 ms |
472 KB |
Output is correct |
16 |
Correct |
86 ms |
344 KB |
Output is correct |
17 |
Correct |
88 ms |
472 KB |
Output is correct |
18 |
Correct |
81 ms |
348 KB |
Output is correct |
19 |
Correct |
2893 ms |
856 KB |
Output is correct |
20 |
Correct |
3824 ms |
660 KB |
Output is correct |
21 |
Correct |
3235 ms |
852 KB |
Output is correct |
22 |
Correct |
3645 ms |
912 KB |
Output is correct |
23 |
Correct |
2094 ms |
656 KB |
Output is correct |
24 |
Correct |
2104 ms |
660 KB |
Output is correct |
25 |
Correct |
2089 ms |
656 KB |
Output is correct |
26 |
Correct |
2196 ms |
656 KB |
Output is correct |
27 |
Correct |
2173 ms |
660 KB |
Output is correct |
28 |
Correct |
2210 ms |
664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1884 KB |
Output is correct |
2 |
Correct |
32 ms |
3112 KB |
Output is correct |
3 |
Correct |
61 ms |
4096 KB |
Output is correct |
4 |
Correct |
55 ms |
4044 KB |
Output is correct |
5 |
Correct |
57 ms |
3932 KB |
Output is correct |
6 |
Correct |
58 ms |
4148 KB |
Output is correct |
7 |
Correct |
54 ms |
4152 KB |
Output is correct |
8 |
Correct |
71 ms |
4152 KB |
Output is correct |
9 |
Correct |
59 ms |
4148 KB |
Output is correct |
10 |
Correct |
46 ms |
4148 KB |
Output is correct |
11 |
Correct |
47 ms |
4152 KB |
Output is correct |
12 |
Correct |
53 ms |
4144 KB |
Output is correct |
13 |
Correct |
43 ms |
3932 KB |
Output is correct |
14 |
Correct |
42 ms |
3932 KB |
Output is correct |
15 |
Correct |
42 ms |
3932 KB |
Output is correct |
16 |
Correct |
39 ms |
3932 KB |
Output is correct |
17 |
Correct |
44 ms |
3932 KB |
Output is correct |
18 |
Correct |
40 ms |
4084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
348 KB |
Output is correct |
2 |
Correct |
28 ms |
348 KB |
Output is correct |
3 |
Correct |
199 ms |
472 KB |
Output is correct |
4 |
Correct |
198 ms |
348 KB |
Output is correct |
5 |
Correct |
189 ms |
344 KB |
Output is correct |
6 |
Correct |
116 ms |
344 KB |
Output is correct |
7 |
Correct |
155 ms |
348 KB |
Output is correct |
8 |
Correct |
181 ms |
468 KB |
Output is correct |
9 |
Correct |
198 ms |
468 KB |
Output is correct |
10 |
Correct |
104 ms |
472 KB |
Output is correct |
11 |
Correct |
101 ms |
348 KB |
Output is correct |
12 |
Correct |
103 ms |
472 KB |
Output is correct |
13 |
Correct |
101 ms |
344 KB |
Output is correct |
14 |
Correct |
102 ms |
472 KB |
Output is correct |
15 |
Correct |
107 ms |
472 KB |
Output is correct |
16 |
Correct |
86 ms |
344 KB |
Output is correct |
17 |
Correct |
88 ms |
472 KB |
Output is correct |
18 |
Correct |
81 ms |
348 KB |
Output is correct |
19 |
Correct |
2893 ms |
856 KB |
Output is correct |
20 |
Correct |
3824 ms |
660 KB |
Output is correct |
21 |
Correct |
3235 ms |
852 KB |
Output is correct |
22 |
Correct |
3645 ms |
912 KB |
Output is correct |
23 |
Correct |
2094 ms |
656 KB |
Output is correct |
24 |
Correct |
2104 ms |
660 KB |
Output is correct |
25 |
Correct |
2089 ms |
656 KB |
Output is correct |
26 |
Correct |
2196 ms |
656 KB |
Output is correct |
27 |
Correct |
2173 ms |
660 KB |
Output is correct |
28 |
Correct |
2210 ms |
664 KB |
Output is correct |
29 |
Correct |
9 ms |
1884 KB |
Output is correct |
30 |
Correct |
32 ms |
3112 KB |
Output is correct |
31 |
Correct |
61 ms |
4096 KB |
Output is correct |
32 |
Correct |
55 ms |
4044 KB |
Output is correct |
33 |
Correct |
57 ms |
3932 KB |
Output is correct |
34 |
Correct |
58 ms |
4148 KB |
Output is correct |
35 |
Correct |
54 ms |
4152 KB |
Output is correct |
36 |
Correct |
71 ms |
4152 KB |
Output is correct |
37 |
Correct |
59 ms |
4148 KB |
Output is correct |
38 |
Correct |
46 ms |
4148 KB |
Output is correct |
39 |
Correct |
47 ms |
4152 KB |
Output is correct |
40 |
Correct |
53 ms |
4144 KB |
Output is correct |
41 |
Correct |
43 ms |
3932 KB |
Output is correct |
42 |
Correct |
42 ms |
3932 KB |
Output is correct |
43 |
Correct |
42 ms |
3932 KB |
Output is correct |
44 |
Correct |
39 ms |
3932 KB |
Output is correct |
45 |
Correct |
44 ms |
3932 KB |
Output is correct |
46 |
Correct |
40 ms |
4084 KB |
Output is correct |
47 |
Runtime error |
42 ms |
8548 KB |
Execution killed with signal 11 |
48 |
Halted |
0 ms |
0 KB |
- |