#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 |
21 ms |
448 KB |
Output is correct |
2 |
Correct |
48 ms |
436 KB |
Output is correct |
3 |
Correct |
352 ms |
484 KB |
Output is correct |
4 |
Correct |
366 ms |
596 KB |
Output is correct |
5 |
Correct |
354 ms |
484 KB |
Output is correct |
6 |
Correct |
260 ms |
344 KB |
Output is correct |
7 |
Correct |
306 ms |
344 KB |
Output is correct |
8 |
Correct |
319 ms |
344 KB |
Output is correct |
9 |
Correct |
325 ms |
348 KB |
Output is correct |
10 |
Correct |
250 ms |
488 KB |
Output is correct |
11 |
Correct |
246 ms |
488 KB |
Output is correct |
12 |
Correct |
254 ms |
488 KB |
Output is correct |
13 |
Correct |
253 ms |
344 KB |
Output is correct |
14 |
Correct |
240 ms |
488 KB |
Output is correct |
15 |
Correct |
237 ms |
484 KB |
Output is correct |
16 |
Correct |
210 ms |
344 KB |
Output is correct |
17 |
Correct |
213 ms |
348 KB |
Output is correct |
18 |
Correct |
203 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
448 KB |
Output is correct |
2 |
Correct |
48 ms |
436 KB |
Output is correct |
3 |
Correct |
352 ms |
484 KB |
Output is correct |
4 |
Correct |
366 ms |
596 KB |
Output is correct |
5 |
Correct |
354 ms |
484 KB |
Output is correct |
6 |
Correct |
260 ms |
344 KB |
Output is correct |
7 |
Correct |
306 ms |
344 KB |
Output is correct |
8 |
Correct |
319 ms |
344 KB |
Output is correct |
9 |
Correct |
325 ms |
348 KB |
Output is correct |
10 |
Correct |
250 ms |
488 KB |
Output is correct |
11 |
Correct |
246 ms |
488 KB |
Output is correct |
12 |
Correct |
254 ms |
488 KB |
Output is correct |
13 |
Correct |
253 ms |
344 KB |
Output is correct |
14 |
Correct |
240 ms |
488 KB |
Output is correct |
15 |
Correct |
237 ms |
484 KB |
Output is correct |
16 |
Correct |
210 ms |
344 KB |
Output is correct |
17 |
Correct |
213 ms |
348 KB |
Output is correct |
18 |
Correct |
203 ms |
348 KB |
Output is correct |
19 |
Correct |
4932 ms |
688 KB |
Output is correct |
20 |
Correct |
6946 ms |
600 KB |
Output is correct |
21 |
Correct |
5405 ms |
600 KB |
Output is correct |
22 |
Correct |
6443 ms |
720 KB |
Output is correct |
23 |
Correct |
4628 ms |
600 KB |
Output is correct |
24 |
Correct |
4524 ms |
720 KB |
Output is correct |
25 |
Correct |
4578 ms |
860 KB |
Output is correct |
26 |
Correct |
4508 ms |
880 KB |
Output is correct |
27 |
Correct |
4542 ms |
872 KB |
Output is correct |
28 |
Correct |
4386 ms |
888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6976 ms |
1116 KB |
Output is correct |
2 |
Execution timed out |
9060 ms |
1884 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
448 KB |
Output is correct |
2 |
Correct |
48 ms |
436 KB |
Output is correct |
3 |
Correct |
352 ms |
484 KB |
Output is correct |
4 |
Correct |
366 ms |
596 KB |
Output is correct |
5 |
Correct |
354 ms |
484 KB |
Output is correct |
6 |
Correct |
260 ms |
344 KB |
Output is correct |
7 |
Correct |
306 ms |
344 KB |
Output is correct |
8 |
Correct |
319 ms |
344 KB |
Output is correct |
9 |
Correct |
325 ms |
348 KB |
Output is correct |
10 |
Correct |
250 ms |
488 KB |
Output is correct |
11 |
Correct |
246 ms |
488 KB |
Output is correct |
12 |
Correct |
254 ms |
488 KB |
Output is correct |
13 |
Correct |
253 ms |
344 KB |
Output is correct |
14 |
Correct |
240 ms |
488 KB |
Output is correct |
15 |
Correct |
237 ms |
484 KB |
Output is correct |
16 |
Correct |
210 ms |
344 KB |
Output is correct |
17 |
Correct |
213 ms |
348 KB |
Output is correct |
18 |
Correct |
203 ms |
348 KB |
Output is correct |
19 |
Correct |
4932 ms |
688 KB |
Output is correct |
20 |
Correct |
6946 ms |
600 KB |
Output is correct |
21 |
Correct |
5405 ms |
600 KB |
Output is correct |
22 |
Correct |
6443 ms |
720 KB |
Output is correct |
23 |
Correct |
4628 ms |
600 KB |
Output is correct |
24 |
Correct |
4524 ms |
720 KB |
Output is correct |
25 |
Correct |
4578 ms |
860 KB |
Output is correct |
26 |
Correct |
4508 ms |
880 KB |
Output is correct |
27 |
Correct |
4542 ms |
872 KB |
Output is correct |
28 |
Correct |
4386 ms |
888 KB |
Output is correct |
29 |
Correct |
6976 ms |
1116 KB |
Output is correct |
30 |
Execution timed out |
9060 ms |
1884 KB |
Time limit exceeded |
31 |
Halted |
0 ms |
0 KB |
- |