#include "bubblesort2.h"
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
using vi = vector<int>;
using pii = pair<int, int>;
#define sz(x) int(x.size())
vi countScans(vi A, vi X, vi V)
{
int N = sz(A);
int Q = sz(X);
vi answer(Q);
for(int j = 0; j < Q; j++)
{
A[X[j]] = V[j];
vector<pii> pos;
for(int i = 0; i < N; i++)
pos.push_back({A[i], i});
sort(pos.begin(), pos.end());
int res = 0;
for(int i = 0; i < N; i++)
{
if(i > 0 && pos[i].first == pos[i-1].first) continue;
res = max(res, pos[i].second - i);
}
answer[j] = res;
}
return answer;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
212 KB |
Output is correct |
2 |
Correct |
50 ms |
212 KB |
Output is correct |
3 |
Correct |
273 ms |
364 KB |
Output is correct |
4 |
Correct |
248 ms |
364 KB |
Output is correct |
5 |
Correct |
239 ms |
360 KB |
Output is correct |
6 |
Correct |
203 ms |
360 KB |
Output is correct |
7 |
Correct |
212 ms |
364 KB |
Output is correct |
8 |
Correct |
227 ms |
364 KB |
Output is correct |
9 |
Correct |
234 ms |
360 KB |
Output is correct |
10 |
Correct |
159 ms |
372 KB |
Output is correct |
11 |
Correct |
167 ms |
368 KB |
Output is correct |
12 |
Correct |
159 ms |
360 KB |
Output is correct |
13 |
Correct |
156 ms |
364 KB |
Output is correct |
14 |
Correct |
153 ms |
340 KB |
Output is correct |
15 |
Correct |
171 ms |
360 KB |
Output is correct |
16 |
Correct |
145 ms |
360 KB |
Output is correct |
17 |
Correct |
148 ms |
368 KB |
Output is correct |
18 |
Correct |
158 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
212 KB |
Output is correct |
2 |
Correct |
50 ms |
212 KB |
Output is correct |
3 |
Correct |
273 ms |
364 KB |
Output is correct |
4 |
Correct |
248 ms |
364 KB |
Output is correct |
5 |
Correct |
239 ms |
360 KB |
Output is correct |
6 |
Correct |
203 ms |
360 KB |
Output is correct |
7 |
Correct |
212 ms |
364 KB |
Output is correct |
8 |
Correct |
227 ms |
364 KB |
Output is correct |
9 |
Correct |
234 ms |
360 KB |
Output is correct |
10 |
Correct |
159 ms |
372 KB |
Output is correct |
11 |
Correct |
167 ms |
368 KB |
Output is correct |
12 |
Correct |
159 ms |
360 KB |
Output is correct |
13 |
Correct |
156 ms |
364 KB |
Output is correct |
14 |
Correct |
153 ms |
340 KB |
Output is correct |
15 |
Correct |
171 ms |
360 KB |
Output is correct |
16 |
Correct |
145 ms |
360 KB |
Output is correct |
17 |
Correct |
148 ms |
368 KB |
Output is correct |
18 |
Correct |
158 ms |
364 KB |
Output is correct |
19 |
Correct |
3354 ms |
600 KB |
Output is correct |
20 |
Correct |
4285 ms |
620 KB |
Output is correct |
21 |
Correct |
3724 ms |
624 KB |
Output is correct |
22 |
Correct |
4113 ms |
628 KB |
Output is correct |
23 |
Correct |
2774 ms |
620 KB |
Output is correct |
24 |
Correct |
2856 ms |
628 KB |
Output is correct |
25 |
Correct |
2938 ms |
624 KB |
Output is correct |
26 |
Correct |
3015 ms |
620 KB |
Output is correct |
27 |
Correct |
2942 ms |
628 KB |
Output is correct |
28 |
Correct |
2992 ms |
624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6194 ms |
1168 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
212 KB |
Output is correct |
2 |
Correct |
50 ms |
212 KB |
Output is correct |
3 |
Correct |
273 ms |
364 KB |
Output is correct |
4 |
Correct |
248 ms |
364 KB |
Output is correct |
5 |
Correct |
239 ms |
360 KB |
Output is correct |
6 |
Correct |
203 ms |
360 KB |
Output is correct |
7 |
Correct |
212 ms |
364 KB |
Output is correct |
8 |
Correct |
227 ms |
364 KB |
Output is correct |
9 |
Correct |
234 ms |
360 KB |
Output is correct |
10 |
Correct |
159 ms |
372 KB |
Output is correct |
11 |
Correct |
167 ms |
368 KB |
Output is correct |
12 |
Correct |
159 ms |
360 KB |
Output is correct |
13 |
Correct |
156 ms |
364 KB |
Output is correct |
14 |
Correct |
153 ms |
340 KB |
Output is correct |
15 |
Correct |
171 ms |
360 KB |
Output is correct |
16 |
Correct |
145 ms |
360 KB |
Output is correct |
17 |
Correct |
148 ms |
368 KB |
Output is correct |
18 |
Correct |
158 ms |
364 KB |
Output is correct |
19 |
Correct |
3354 ms |
600 KB |
Output is correct |
20 |
Correct |
4285 ms |
620 KB |
Output is correct |
21 |
Correct |
3724 ms |
624 KB |
Output is correct |
22 |
Correct |
4113 ms |
628 KB |
Output is correct |
23 |
Correct |
2774 ms |
620 KB |
Output is correct |
24 |
Correct |
2856 ms |
628 KB |
Output is correct |
25 |
Correct |
2938 ms |
624 KB |
Output is correct |
26 |
Correct |
3015 ms |
620 KB |
Output is correct |
27 |
Correct |
2942 ms |
628 KB |
Output is correct |
28 |
Correct |
2992 ms |
624 KB |
Output is correct |
29 |
Incorrect |
6194 ms |
1168 KB |
Output isn't correct |
30 |
Halted |
0 ms |
0 KB |
- |