#include "bubblesort2.h"
#define ll long long
#define fi first
#define se second
#define pb push_back
using namespace std;
vector <int> countScans(vector <int> a, vector <int> x, vector <int> v) {
int n = a.size(), q = x.size();
if (n > 8000 || q > 8000)
return {};
vector <int> cnt, anss = {}; cnt.assign(n, 0);
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++)
if (a[i] > a[j])
cnt[j]++;
for (int i = 0; i < q; i++) {
int pos = x[i], val = v[i];
for (int j = pos + 1; j < n; j++)
if (a[pos] <= a[j] && a[j] < val)
cnt[j]++;
else if (val <= a[j] && a[j] < a[pos])
cnt[j]--;
cnt[pos] = 0;
for (int j = 0; j < pos; j++)
if (a[j] > val)
cnt[pos]++;
a[pos] = val;
int ans = 0;
for (int j = 0; j < n; j++)
ans = max(ans, cnt[j]);
anss.pb(ans);
}
return anss;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
364 KB |
Output is correct |
2 |
Correct |
6 ms |
364 KB |
Output is correct |
3 |
Correct |
30 ms |
512 KB |
Output is correct |
4 |
Correct |
30 ms |
492 KB |
Output is correct |
5 |
Correct |
24 ms |
492 KB |
Output is correct |
6 |
Correct |
16 ms |
512 KB |
Output is correct |
7 |
Correct |
19 ms |
364 KB |
Output is correct |
8 |
Correct |
21 ms |
492 KB |
Output is correct |
9 |
Correct |
29 ms |
504 KB |
Output is correct |
10 |
Correct |
19 ms |
372 KB |
Output is correct |
11 |
Correct |
21 ms |
492 KB |
Output is correct |
12 |
Correct |
23 ms |
492 KB |
Output is correct |
13 |
Correct |
19 ms |
492 KB |
Output is correct |
14 |
Correct |
19 ms |
492 KB |
Output is correct |
15 |
Correct |
19 ms |
492 KB |
Output is correct |
16 |
Correct |
17 ms |
492 KB |
Output is correct |
17 |
Correct |
17 ms |
492 KB |
Output is correct |
18 |
Correct |
19 ms |
492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
364 KB |
Output is correct |
2 |
Correct |
6 ms |
364 KB |
Output is correct |
3 |
Correct |
30 ms |
512 KB |
Output is correct |
4 |
Correct |
30 ms |
492 KB |
Output is correct |
5 |
Correct |
24 ms |
492 KB |
Output is correct |
6 |
Correct |
16 ms |
512 KB |
Output is correct |
7 |
Correct |
19 ms |
364 KB |
Output is correct |
8 |
Correct |
21 ms |
492 KB |
Output is correct |
9 |
Correct |
29 ms |
504 KB |
Output is correct |
10 |
Correct |
19 ms |
372 KB |
Output is correct |
11 |
Correct |
21 ms |
492 KB |
Output is correct |
12 |
Correct |
23 ms |
492 KB |
Output is correct |
13 |
Correct |
19 ms |
492 KB |
Output is correct |
14 |
Correct |
19 ms |
492 KB |
Output is correct |
15 |
Correct |
19 ms |
492 KB |
Output is correct |
16 |
Correct |
17 ms |
492 KB |
Output is correct |
17 |
Correct |
17 ms |
492 KB |
Output is correct |
18 |
Correct |
19 ms |
492 KB |
Output is correct |
19 |
Correct |
381 ms |
876 KB |
Output is correct |
20 |
Correct |
481 ms |
908 KB |
Output is correct |
21 |
Correct |
286 ms |
876 KB |
Output is correct |
22 |
Correct |
366 ms |
876 KB |
Output is correct |
23 |
Correct |
291 ms |
748 KB |
Output is correct |
24 |
Correct |
291 ms |
748 KB |
Output is correct |
25 |
Correct |
279 ms |
748 KB |
Output is correct |
26 |
Correct |
280 ms |
748 KB |
Output is correct |
27 |
Correct |
267 ms |
768 KB |
Output is correct |
28 |
Correct |
261 ms |
748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
620 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
364 KB |
Output is correct |
2 |
Correct |
6 ms |
364 KB |
Output is correct |
3 |
Correct |
30 ms |
512 KB |
Output is correct |
4 |
Correct |
30 ms |
492 KB |
Output is correct |
5 |
Correct |
24 ms |
492 KB |
Output is correct |
6 |
Correct |
16 ms |
512 KB |
Output is correct |
7 |
Correct |
19 ms |
364 KB |
Output is correct |
8 |
Correct |
21 ms |
492 KB |
Output is correct |
9 |
Correct |
29 ms |
504 KB |
Output is correct |
10 |
Correct |
19 ms |
372 KB |
Output is correct |
11 |
Correct |
21 ms |
492 KB |
Output is correct |
12 |
Correct |
23 ms |
492 KB |
Output is correct |
13 |
Correct |
19 ms |
492 KB |
Output is correct |
14 |
Correct |
19 ms |
492 KB |
Output is correct |
15 |
Correct |
19 ms |
492 KB |
Output is correct |
16 |
Correct |
17 ms |
492 KB |
Output is correct |
17 |
Correct |
17 ms |
492 KB |
Output is correct |
18 |
Correct |
19 ms |
492 KB |
Output is correct |
19 |
Correct |
381 ms |
876 KB |
Output is correct |
20 |
Correct |
481 ms |
908 KB |
Output is correct |
21 |
Correct |
286 ms |
876 KB |
Output is correct |
22 |
Correct |
366 ms |
876 KB |
Output is correct |
23 |
Correct |
291 ms |
748 KB |
Output is correct |
24 |
Correct |
291 ms |
748 KB |
Output is correct |
25 |
Correct |
279 ms |
748 KB |
Output is correct |
26 |
Correct |
280 ms |
748 KB |
Output is correct |
27 |
Correct |
267 ms |
768 KB |
Output is correct |
28 |
Correct |
261 ms |
748 KB |
Output is correct |
29 |
Incorrect |
4 ms |
620 KB |
Output isn't correct |
30 |
Halted |
0 ms |
0 KB |
- |