#pragma GCC optimize ("Ofast")
#include "bubblesort2.h"
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
const int N = 8000, inf = INT_MAX;
int n;
vector<int> a;
vector<pair<int, int>> b;
int solve() {
for (int i = 0; i < n; i++) {
b[i] = make_pair(a[i], i);
}
sort(all(b));
int mx = 0;
int mn = inf;
for (int i = n-1; i >= 0; i--) {
mn = min(mn, a[i]);
if (mn < a[i]) continue;
int idx = lower_bound(all(b), make_pair(a[i], i)) - b.begin();
mx = max(mx, i - idx);
}
return mx;
}
vector<int> countScans(vector<int> A, vector<int> X, vector<int> V){
n = A.size();
int q = X.size();
vector<int> ans(q);
a.resize(n);
for (int i = 0; i < n; i++) {
a[i] = A[i];
}
b.resize(n);
for (int j = 0; j < q; j++) {
a[X[j]] = V[j];
ans[j] = solve();
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
344 KB |
Output is correct |
2 |
Correct |
21 ms |
348 KB |
Output is correct |
3 |
Correct |
139 ms |
492 KB |
Output is correct |
4 |
Correct |
144 ms |
348 KB |
Output is correct |
5 |
Correct |
159 ms |
348 KB |
Output is correct |
6 |
Correct |
211 ms |
348 KB |
Output is correct |
7 |
Correct |
225 ms |
344 KB |
Output is correct |
8 |
Correct |
200 ms |
344 KB |
Output is correct |
9 |
Correct |
135 ms |
348 KB |
Output is correct |
10 |
Correct |
120 ms |
488 KB |
Output is correct |
11 |
Correct |
120 ms |
348 KB |
Output is correct |
12 |
Correct |
119 ms |
348 KB |
Output is correct |
13 |
Correct |
120 ms |
348 KB |
Output is correct |
14 |
Correct |
119 ms |
348 KB |
Output is correct |
15 |
Correct |
120 ms |
344 KB |
Output is correct |
16 |
Correct |
99 ms |
344 KB |
Output is correct |
17 |
Correct |
102 ms |
348 KB |
Output is correct |
18 |
Correct |
93 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
344 KB |
Output is correct |
2 |
Correct |
21 ms |
348 KB |
Output is correct |
3 |
Correct |
139 ms |
492 KB |
Output is correct |
4 |
Correct |
144 ms |
348 KB |
Output is correct |
5 |
Correct |
159 ms |
348 KB |
Output is correct |
6 |
Correct |
211 ms |
348 KB |
Output is correct |
7 |
Correct |
225 ms |
344 KB |
Output is correct |
8 |
Correct |
200 ms |
344 KB |
Output is correct |
9 |
Correct |
135 ms |
348 KB |
Output is correct |
10 |
Correct |
120 ms |
488 KB |
Output is correct |
11 |
Correct |
120 ms |
348 KB |
Output is correct |
12 |
Correct |
119 ms |
348 KB |
Output is correct |
13 |
Correct |
120 ms |
348 KB |
Output is correct |
14 |
Correct |
119 ms |
348 KB |
Output is correct |
15 |
Correct |
120 ms |
344 KB |
Output is correct |
16 |
Correct |
99 ms |
344 KB |
Output is correct |
17 |
Correct |
102 ms |
348 KB |
Output is correct |
18 |
Correct |
93 ms |
348 KB |
Output is correct |
19 |
Correct |
2154 ms |
600 KB |
Output is correct |
20 |
Correct |
2809 ms |
728 KB |
Output is correct |
21 |
Correct |
4094 ms |
724 KB |
Output is correct |
22 |
Correct |
3100 ms |
604 KB |
Output is correct |
23 |
Correct |
2723 ms |
720 KB |
Output is correct |
24 |
Correct |
2717 ms |
604 KB |
Output is correct |
25 |
Correct |
2648 ms |
720 KB |
Output is correct |
26 |
Correct |
2693 ms |
604 KB |
Output is correct |
27 |
Correct |
2728 ms |
848 KB |
Output is correct |
28 |
Correct |
2737 ms |
720 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3779 ms |
1000 KB |
Output is correct |
2 |
Execution timed out |
9019 ms |
1880 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
344 KB |
Output is correct |
2 |
Correct |
21 ms |
348 KB |
Output is correct |
3 |
Correct |
139 ms |
492 KB |
Output is correct |
4 |
Correct |
144 ms |
348 KB |
Output is correct |
5 |
Correct |
159 ms |
348 KB |
Output is correct |
6 |
Correct |
211 ms |
348 KB |
Output is correct |
7 |
Correct |
225 ms |
344 KB |
Output is correct |
8 |
Correct |
200 ms |
344 KB |
Output is correct |
9 |
Correct |
135 ms |
348 KB |
Output is correct |
10 |
Correct |
120 ms |
488 KB |
Output is correct |
11 |
Correct |
120 ms |
348 KB |
Output is correct |
12 |
Correct |
119 ms |
348 KB |
Output is correct |
13 |
Correct |
120 ms |
348 KB |
Output is correct |
14 |
Correct |
119 ms |
348 KB |
Output is correct |
15 |
Correct |
120 ms |
344 KB |
Output is correct |
16 |
Correct |
99 ms |
344 KB |
Output is correct |
17 |
Correct |
102 ms |
348 KB |
Output is correct |
18 |
Correct |
93 ms |
348 KB |
Output is correct |
19 |
Correct |
2154 ms |
600 KB |
Output is correct |
20 |
Correct |
2809 ms |
728 KB |
Output is correct |
21 |
Correct |
4094 ms |
724 KB |
Output is correct |
22 |
Correct |
3100 ms |
604 KB |
Output is correct |
23 |
Correct |
2723 ms |
720 KB |
Output is correct |
24 |
Correct |
2717 ms |
604 KB |
Output is correct |
25 |
Correct |
2648 ms |
720 KB |
Output is correct |
26 |
Correct |
2693 ms |
604 KB |
Output is correct |
27 |
Correct |
2728 ms |
848 KB |
Output is correct |
28 |
Correct |
2737 ms |
720 KB |
Output is correct |
29 |
Correct |
3779 ms |
1000 KB |
Output is correct |
30 |
Execution timed out |
9019 ms |
1880 KB |
Time limit exceeded |
31 |
Halted |
0 ms |
0 KB |
- |