#include "bubblesort2.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int NAX = (int) 1e6 + 7;
int N;
int coef[NAX];
bool valid[NAX];
vector<int> innterCountScans(vector<ll> a, vector<int> pos, vector<ll> value) {
int n = (int) a.size();
int q = (int) pos.size();
for (int i = 0; i < n; i++) {
a[i] = a[i] * (ll) (n + 1) + i;
}
assert(q == (int) value.size());
for (int it = 0; it < q; it++) {
value[it] = value[it] * (ll) (n + 1) + pos[it];
}
map<ll, int> mp;
for (auto &x : a) {
mp[x] = 0;
}
for (auto &x : value) {
mp[x] = 0;
}
{
int ij = 0;
for (auto &it : mp) {
it.second = ++ij;
}
N = ij;
assert(N <= n + q);
}
for (auto &x : a) {
x = mp[x];
}
for (auto &x : value) {
x = mp[x];
}
for (int i = 0; i < n; i++) {
valid[a[i]] = 1;
coef[a[i]] = i;
}
vector<int> sol;
for (int it = 0; it < q; it++) {
valid[a[pos[it]]] = 0;
a[pos[it]] = value[it];
valid[a[pos[it]]] = 1;
coef[a[pos[it]]] = pos[it];
int cnt = 0, MX = 0;
for (int i = 1; i <= N; i++) {
if (valid[i]) {
cnt++;
MX = max(MX, coef[i] - cnt);
}
}
sol.push_back(MX + 1);
}
return sol;
}
vector<int> countScans(vector<int> a, vector<int> b, vector<int> c) {
vector<ll> X, Z;
for (auto &it : a) {
X.push_back(it);
}
for (auto &it : c) {
Z.push_back(it);
}
return innterCountScans(X, b, Z);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
332 KB |
Output is correct |
2 |
Correct |
5 ms |
476 KB |
Output is correct |
3 |
Correct |
23 ms |
716 KB |
Output is correct |
4 |
Correct |
23 ms |
712 KB |
Output is correct |
5 |
Correct |
24 ms |
700 KB |
Output is correct |
6 |
Correct |
21 ms |
712 KB |
Output is correct |
7 |
Correct |
22 ms |
700 KB |
Output is correct |
8 |
Correct |
22 ms |
708 KB |
Output is correct |
9 |
Correct |
23 ms |
728 KB |
Output is correct |
10 |
Correct |
17 ms |
660 KB |
Output is correct |
11 |
Correct |
16 ms |
588 KB |
Output is correct |
12 |
Correct |
16 ms |
588 KB |
Output is correct |
13 |
Correct |
13 ms |
652 KB |
Output is correct |
14 |
Correct |
14 ms |
656 KB |
Output is correct |
15 |
Correct |
16 ms |
656 KB |
Output is correct |
16 |
Correct |
12 ms |
628 KB |
Output is correct |
17 |
Correct |
16 ms |
588 KB |
Output is correct |
18 |
Correct |
14 ms |
628 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
332 KB |
Output is correct |
2 |
Correct |
5 ms |
476 KB |
Output is correct |
3 |
Correct |
23 ms |
716 KB |
Output is correct |
4 |
Correct |
23 ms |
712 KB |
Output is correct |
5 |
Correct |
24 ms |
700 KB |
Output is correct |
6 |
Correct |
21 ms |
712 KB |
Output is correct |
7 |
Correct |
22 ms |
700 KB |
Output is correct |
8 |
Correct |
22 ms |
708 KB |
Output is correct |
9 |
Correct |
23 ms |
728 KB |
Output is correct |
10 |
Correct |
17 ms |
660 KB |
Output is correct |
11 |
Correct |
16 ms |
588 KB |
Output is correct |
12 |
Correct |
16 ms |
588 KB |
Output is correct |
13 |
Correct |
13 ms |
652 KB |
Output is correct |
14 |
Correct |
14 ms |
656 KB |
Output is correct |
15 |
Correct |
16 ms |
656 KB |
Output is correct |
16 |
Correct |
12 ms |
628 KB |
Output is correct |
17 |
Correct |
16 ms |
588 KB |
Output is correct |
18 |
Correct |
14 ms |
628 KB |
Output is correct |
19 |
Correct |
347 ms |
1684 KB |
Output is correct |
20 |
Correct |
458 ms |
2020 KB |
Output is correct |
21 |
Correct |
426 ms |
1860 KB |
Output is correct |
22 |
Correct |
455 ms |
2096 KB |
Output is correct |
23 |
Correct |
294 ms |
1972 KB |
Output is correct |
24 |
Correct |
292 ms |
1904 KB |
Output is correct |
25 |
Correct |
255 ms |
1864 KB |
Output is correct |
26 |
Correct |
273 ms |
1864 KB |
Output is correct |
27 |
Correct |
238 ms |
1820 KB |
Output is correct |
28 |
Correct |
239 ms |
1876 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
101 ms |
3044 KB |
Output is correct |
2 |
Correct |
5895 ms |
6796 KB |
Output is correct |
3 |
Execution timed out |
9070 ms |
10840 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
332 KB |
Output is correct |
2 |
Correct |
5 ms |
476 KB |
Output is correct |
3 |
Correct |
23 ms |
716 KB |
Output is correct |
4 |
Correct |
23 ms |
712 KB |
Output is correct |
5 |
Correct |
24 ms |
700 KB |
Output is correct |
6 |
Correct |
21 ms |
712 KB |
Output is correct |
7 |
Correct |
22 ms |
700 KB |
Output is correct |
8 |
Correct |
22 ms |
708 KB |
Output is correct |
9 |
Correct |
23 ms |
728 KB |
Output is correct |
10 |
Correct |
17 ms |
660 KB |
Output is correct |
11 |
Correct |
16 ms |
588 KB |
Output is correct |
12 |
Correct |
16 ms |
588 KB |
Output is correct |
13 |
Correct |
13 ms |
652 KB |
Output is correct |
14 |
Correct |
14 ms |
656 KB |
Output is correct |
15 |
Correct |
16 ms |
656 KB |
Output is correct |
16 |
Correct |
12 ms |
628 KB |
Output is correct |
17 |
Correct |
16 ms |
588 KB |
Output is correct |
18 |
Correct |
14 ms |
628 KB |
Output is correct |
19 |
Correct |
347 ms |
1684 KB |
Output is correct |
20 |
Correct |
458 ms |
2020 KB |
Output is correct |
21 |
Correct |
426 ms |
1860 KB |
Output is correct |
22 |
Correct |
455 ms |
2096 KB |
Output is correct |
23 |
Correct |
294 ms |
1972 KB |
Output is correct |
24 |
Correct |
292 ms |
1904 KB |
Output is correct |
25 |
Correct |
255 ms |
1864 KB |
Output is correct |
26 |
Correct |
273 ms |
1864 KB |
Output is correct |
27 |
Correct |
238 ms |
1820 KB |
Output is correct |
28 |
Correct |
239 ms |
1876 KB |
Output is correct |
29 |
Correct |
101 ms |
3044 KB |
Output is correct |
30 |
Correct |
5895 ms |
6796 KB |
Output is correct |
31 |
Execution timed out |
9070 ms |
10840 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |