#include "bubblesort2.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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];
}
vector<int> sol;
for (int it = 0; it < q; it++) {
a[pos[it]] = value[it];
map<ll, int> mp;
for (auto &x : a) {
mp[x] = 0;
}
{
int ij = 0;
for (auto &it : mp) {
it.second = ++ij;
}
}
ll MN = a[n - 1];
int MX = 0;
for (int i = n - 1; i >= 0; i--) {
MN = min(MN, a[i]);
if (a[i] == MN) {
/// a[i] = minim pe sufix => (a[i] - 1)
MX = max(MX, i - mp[a[i]]);
}
}
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 |
36 ms |
352 KB |
Output is correct |
2 |
Correct |
92 ms |
388 KB |
Output is correct |
3 |
Correct |
640 ms |
528 KB |
Output is correct |
4 |
Correct |
633 ms |
528 KB |
Output is correct |
5 |
Correct |
616 ms |
528 KB |
Output is correct |
6 |
Correct |
787 ms |
524 KB |
Output is correct |
7 |
Correct |
750 ms |
528 KB |
Output is correct |
8 |
Correct |
762 ms |
512 KB |
Output is correct |
9 |
Correct |
651 ms |
520 KB |
Output is correct |
10 |
Correct |
624 ms |
532 KB |
Output is correct |
11 |
Correct |
614 ms |
512 KB |
Output is correct |
12 |
Correct |
611 ms |
524 KB |
Output is correct |
13 |
Correct |
597 ms |
528 KB |
Output is correct |
14 |
Correct |
642 ms |
532 KB |
Output is correct |
15 |
Correct |
613 ms |
532 KB |
Output is correct |
16 |
Correct |
635 ms |
652 KB |
Output is correct |
17 |
Correct |
621 ms |
508 KB |
Output is correct |
18 |
Correct |
632 ms |
652 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
352 KB |
Output is correct |
2 |
Correct |
92 ms |
388 KB |
Output is correct |
3 |
Correct |
640 ms |
528 KB |
Output is correct |
4 |
Correct |
633 ms |
528 KB |
Output is correct |
5 |
Correct |
616 ms |
528 KB |
Output is correct |
6 |
Correct |
787 ms |
524 KB |
Output is correct |
7 |
Correct |
750 ms |
528 KB |
Output is correct |
8 |
Correct |
762 ms |
512 KB |
Output is correct |
9 |
Correct |
651 ms |
520 KB |
Output is correct |
10 |
Correct |
624 ms |
532 KB |
Output is correct |
11 |
Correct |
614 ms |
512 KB |
Output is correct |
12 |
Correct |
611 ms |
524 KB |
Output is correct |
13 |
Correct |
597 ms |
528 KB |
Output is correct |
14 |
Correct |
642 ms |
532 KB |
Output is correct |
15 |
Correct |
613 ms |
532 KB |
Output is correct |
16 |
Correct |
635 ms |
652 KB |
Output is correct |
17 |
Correct |
621 ms |
508 KB |
Output is correct |
18 |
Correct |
632 ms |
652 KB |
Output is correct |
19 |
Execution timed out |
9073 ms |
1224 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
9074 ms |
2748 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
352 KB |
Output is correct |
2 |
Correct |
92 ms |
388 KB |
Output is correct |
3 |
Correct |
640 ms |
528 KB |
Output is correct |
4 |
Correct |
633 ms |
528 KB |
Output is correct |
5 |
Correct |
616 ms |
528 KB |
Output is correct |
6 |
Correct |
787 ms |
524 KB |
Output is correct |
7 |
Correct |
750 ms |
528 KB |
Output is correct |
8 |
Correct |
762 ms |
512 KB |
Output is correct |
9 |
Correct |
651 ms |
520 KB |
Output is correct |
10 |
Correct |
624 ms |
532 KB |
Output is correct |
11 |
Correct |
614 ms |
512 KB |
Output is correct |
12 |
Correct |
611 ms |
524 KB |
Output is correct |
13 |
Correct |
597 ms |
528 KB |
Output is correct |
14 |
Correct |
642 ms |
532 KB |
Output is correct |
15 |
Correct |
613 ms |
532 KB |
Output is correct |
16 |
Correct |
635 ms |
652 KB |
Output is correct |
17 |
Correct |
621 ms |
508 KB |
Output is correct |
18 |
Correct |
632 ms |
652 KB |
Output is correct |
19 |
Execution timed out |
9073 ms |
1224 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |