#include "bubblesort2.h"
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
//#define int ll
#define sz(x) ((x).size())
int get(vector<int> V) {
int n = sz(V);
vector<int> idx(n);
iota(all(idx), 0);
sort(all(idx), [&](int a, int b) { return V[a] < V[b] || (V[a] == V[b] && a < b); } );
int mx = 0, cnt = 0;
for(auto x : idx)
// cerr << V[x] << ' ' << x << ' ' << cnt << '\n',
mx = max(mx, x - cnt),
cnt++;
return mx;
}
std::vector<int> countScans(std::vector<int> A,std::vector<int> X,std::vector<int> V){
int Q=X.size();
std::vector<int> answer(Q);
for (int j=0;j<Q;j++) {
A[X[j]] = V[j];
answer[j] = get(A);
}
return answer;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
344 KB |
Output is correct |
2 |
Correct |
34 ms |
500 KB |
Output is correct |
3 |
Correct |
237 ms |
528 KB |
Output is correct |
4 |
Correct |
235 ms |
528 KB |
Output is correct |
5 |
Correct |
224 ms |
344 KB |
Output is correct |
6 |
Correct |
128 ms |
348 KB |
Output is correct |
7 |
Correct |
181 ms |
344 KB |
Output is correct |
8 |
Correct |
208 ms |
540 KB |
Output is correct |
9 |
Correct |
227 ms |
524 KB |
Output is correct |
10 |
Correct |
123 ms |
348 KB |
Output is correct |
11 |
Correct |
120 ms |
600 KB |
Output is correct |
12 |
Correct |
123 ms |
348 KB |
Output is correct |
13 |
Correct |
120 ms |
520 KB |
Output is correct |
14 |
Correct |
127 ms |
516 KB |
Output is correct |
15 |
Correct |
120 ms |
516 KB |
Output is correct |
16 |
Correct |
96 ms |
516 KB |
Output is correct |
17 |
Correct |
102 ms |
348 KB |
Output is correct |
18 |
Correct |
88 ms |
600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
344 KB |
Output is correct |
2 |
Correct |
34 ms |
500 KB |
Output is correct |
3 |
Correct |
237 ms |
528 KB |
Output is correct |
4 |
Correct |
235 ms |
528 KB |
Output is correct |
5 |
Correct |
224 ms |
344 KB |
Output is correct |
6 |
Correct |
128 ms |
348 KB |
Output is correct |
7 |
Correct |
181 ms |
344 KB |
Output is correct |
8 |
Correct |
208 ms |
540 KB |
Output is correct |
9 |
Correct |
227 ms |
524 KB |
Output is correct |
10 |
Correct |
123 ms |
348 KB |
Output is correct |
11 |
Correct |
120 ms |
600 KB |
Output is correct |
12 |
Correct |
123 ms |
348 KB |
Output is correct |
13 |
Correct |
120 ms |
520 KB |
Output is correct |
14 |
Correct |
127 ms |
516 KB |
Output is correct |
15 |
Correct |
120 ms |
516 KB |
Output is correct |
16 |
Correct |
96 ms |
516 KB |
Output is correct |
17 |
Correct |
102 ms |
348 KB |
Output is correct |
18 |
Correct |
88 ms |
600 KB |
Output is correct |
19 |
Correct |
3479 ms |
824 KB |
Output is correct |
20 |
Correct |
4602 ms |
880 KB |
Output is correct |
21 |
Correct |
3781 ms |
880 KB |
Output is correct |
22 |
Correct |
4437 ms |
884 KB |
Output is correct |
23 |
Correct |
2467 ms |
856 KB |
Output is correct |
24 |
Correct |
2477 ms |
860 KB |
Output is correct |
25 |
Correct |
2432 ms |
860 KB |
Output is correct |
26 |
Correct |
2478 ms |
856 KB |
Output is correct |
27 |
Correct |
2405 ms |
860 KB |
Output is correct |
28 |
Correct |
2390 ms |
860 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4860 ms |
1352 KB |
Output is correct |
2 |
Execution timed out |
9026 ms |
2428 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
344 KB |
Output is correct |
2 |
Correct |
34 ms |
500 KB |
Output is correct |
3 |
Correct |
237 ms |
528 KB |
Output is correct |
4 |
Correct |
235 ms |
528 KB |
Output is correct |
5 |
Correct |
224 ms |
344 KB |
Output is correct |
6 |
Correct |
128 ms |
348 KB |
Output is correct |
7 |
Correct |
181 ms |
344 KB |
Output is correct |
8 |
Correct |
208 ms |
540 KB |
Output is correct |
9 |
Correct |
227 ms |
524 KB |
Output is correct |
10 |
Correct |
123 ms |
348 KB |
Output is correct |
11 |
Correct |
120 ms |
600 KB |
Output is correct |
12 |
Correct |
123 ms |
348 KB |
Output is correct |
13 |
Correct |
120 ms |
520 KB |
Output is correct |
14 |
Correct |
127 ms |
516 KB |
Output is correct |
15 |
Correct |
120 ms |
516 KB |
Output is correct |
16 |
Correct |
96 ms |
516 KB |
Output is correct |
17 |
Correct |
102 ms |
348 KB |
Output is correct |
18 |
Correct |
88 ms |
600 KB |
Output is correct |
19 |
Correct |
3479 ms |
824 KB |
Output is correct |
20 |
Correct |
4602 ms |
880 KB |
Output is correct |
21 |
Correct |
3781 ms |
880 KB |
Output is correct |
22 |
Correct |
4437 ms |
884 KB |
Output is correct |
23 |
Correct |
2467 ms |
856 KB |
Output is correct |
24 |
Correct |
2477 ms |
860 KB |
Output is correct |
25 |
Correct |
2432 ms |
860 KB |
Output is correct |
26 |
Correct |
2478 ms |
856 KB |
Output is correct |
27 |
Correct |
2405 ms |
860 KB |
Output is correct |
28 |
Correct |
2390 ms |
860 KB |
Output is correct |
29 |
Correct |
4860 ms |
1352 KB |
Output is correct |
30 |
Execution timed out |
9026 ms |
2428 KB |
Time limit exceeded |
31 |
Halted |
0 ms |
0 KB |
- |