#include "bubblesort2.h"
#include <bits/stdc++.h>
using namespace std;
const int INF = (int) 1e9 + 7;
vector<int> countScans(vector<int> a, vector<int> pos, vector<int> value){
int n = (int) a.size();
int q = (int) pos.size();
assert(q == (int) value.size());
vector<int> sol;
for (int it = 0; it < q; it++) {
a[pos[it]] = value[it];
int MN = INF;
int MX = 0;
for (int i = n - 1; i >= 0; i--) {
MN = min(MN, a[i]);
if (a[i] == MN) {
int bigger = 0;
for (int j = 0; j < i; j++) {
if (a[j] > a[i]) {
bigger++;
}
}
MX = max(MX, bigger);
}
}
sol.push_back(MX);
}
return sol;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
308 KB |
Output is correct |
2 |
Correct |
3 ms |
204 KB |
Output is correct |
3 |
Correct |
20 ms |
352 KB |
Output is correct |
4 |
Correct |
41 ms |
336 KB |
Output is correct |
5 |
Correct |
318 ms |
332 KB |
Output is correct |
6 |
Correct |
2539 ms |
444 KB |
Output is correct |
7 |
Correct |
2029 ms |
440 KB |
Output is correct |
8 |
Correct |
1415 ms |
332 KB |
Output is correct |
9 |
Correct |
231 ms |
444 KB |
Output is correct |
10 |
Correct |
2242 ms |
448 KB |
Output is correct |
11 |
Correct |
2181 ms |
332 KB |
Output is correct |
12 |
Correct |
2206 ms |
328 KB |
Output is correct |
13 |
Correct |
2203 ms |
340 KB |
Output is correct |
14 |
Correct |
2193 ms |
328 KB |
Output is correct |
15 |
Correct |
2216 ms |
332 KB |
Output is correct |
16 |
Correct |
2241 ms |
328 KB |
Output is correct |
17 |
Correct |
2238 ms |
332 KB |
Output is correct |
18 |
Correct |
2215 ms |
456 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
308 KB |
Output is correct |
2 |
Correct |
3 ms |
204 KB |
Output is correct |
3 |
Correct |
20 ms |
352 KB |
Output is correct |
4 |
Correct |
41 ms |
336 KB |
Output is correct |
5 |
Correct |
318 ms |
332 KB |
Output is correct |
6 |
Correct |
2539 ms |
444 KB |
Output is correct |
7 |
Correct |
2029 ms |
440 KB |
Output is correct |
8 |
Correct |
1415 ms |
332 KB |
Output is correct |
9 |
Correct |
231 ms |
444 KB |
Output is correct |
10 |
Correct |
2242 ms |
448 KB |
Output is correct |
11 |
Correct |
2181 ms |
332 KB |
Output is correct |
12 |
Correct |
2206 ms |
328 KB |
Output is correct |
13 |
Correct |
2203 ms |
340 KB |
Output is correct |
14 |
Correct |
2193 ms |
328 KB |
Output is correct |
15 |
Correct |
2216 ms |
332 KB |
Output is correct |
16 |
Correct |
2241 ms |
328 KB |
Output is correct |
17 |
Correct |
2238 ms |
332 KB |
Output is correct |
18 |
Correct |
2215 ms |
456 KB |
Output is correct |
19 |
Correct |
349 ms |
496 KB |
Output is correct |
20 |
Correct |
396 ms |
668 KB |
Output is correct |
21 |
Execution timed out |
9014 ms |
780 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6379 ms |
544 KB |
Output is correct |
2 |
Execution timed out |
9094 ms |
1308 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
308 KB |
Output is correct |
2 |
Correct |
3 ms |
204 KB |
Output is correct |
3 |
Correct |
20 ms |
352 KB |
Output is correct |
4 |
Correct |
41 ms |
336 KB |
Output is correct |
5 |
Correct |
318 ms |
332 KB |
Output is correct |
6 |
Correct |
2539 ms |
444 KB |
Output is correct |
7 |
Correct |
2029 ms |
440 KB |
Output is correct |
8 |
Correct |
1415 ms |
332 KB |
Output is correct |
9 |
Correct |
231 ms |
444 KB |
Output is correct |
10 |
Correct |
2242 ms |
448 KB |
Output is correct |
11 |
Correct |
2181 ms |
332 KB |
Output is correct |
12 |
Correct |
2206 ms |
328 KB |
Output is correct |
13 |
Correct |
2203 ms |
340 KB |
Output is correct |
14 |
Correct |
2193 ms |
328 KB |
Output is correct |
15 |
Correct |
2216 ms |
332 KB |
Output is correct |
16 |
Correct |
2241 ms |
328 KB |
Output is correct |
17 |
Correct |
2238 ms |
332 KB |
Output is correct |
18 |
Correct |
2215 ms |
456 KB |
Output is correct |
19 |
Correct |
349 ms |
496 KB |
Output is correct |
20 |
Correct |
396 ms |
668 KB |
Output is correct |
21 |
Execution timed out |
9014 ms |
780 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |