#include "bubblesort2.h"
#include<bits/stdc++.h>
using namespace std;
struct Dynamic_segtree {
};
vector<int> countScans(vector<int> a, vector<int> x, vector<int> v){
int q = x.size();
int n = a.size();
vector<int> answer(q);
vector<int> inv(n);
for(int i=0; i<n; ++i) {
for(int j=i+1; j<n; ++j) {
if(a[i] > a[j]) {
inv[j]++;
}
}
}
for(int i=0; i<q; ++i) {
int old = a[x[i]];
a[x[i]] = v[i];
inv[x[i]] = 0;
for(int j=0; j<x[i]; ++j) {
if(a[j] > a[x[i]]) {
inv[x[i]]++;
}
}
for(int j=x[i]+1; j<n; ++j) {
if(a[x[i]] > a[j] && old <= a[j]) {
inv[j]++;
}
if(a[x[i]] <= a[j] && old > a[j]) {
inv[j]--;
}
}
for(int j=0; j<n; ++j) {
answer[i] = max(answer[i], inv[j]);
}
}
return answer;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
8 ms |
384 KB |
Output is correct |
3 |
Correct |
31 ms |
416 KB |
Output is correct |
4 |
Correct |
32 ms |
384 KB |
Output is correct |
5 |
Correct |
24 ms |
384 KB |
Output is correct |
6 |
Correct |
16 ms |
384 KB |
Output is correct |
7 |
Correct |
23 ms |
384 KB |
Output is correct |
8 |
Correct |
36 ms |
384 KB |
Output is correct |
9 |
Correct |
29 ms |
384 KB |
Output is correct |
10 |
Correct |
21 ms |
432 KB |
Output is correct |
11 |
Correct |
19 ms |
384 KB |
Output is correct |
12 |
Correct |
20 ms |
384 KB |
Output is correct |
13 |
Correct |
19 ms |
472 KB |
Output is correct |
14 |
Correct |
23 ms |
384 KB |
Output is correct |
15 |
Correct |
33 ms |
416 KB |
Output is correct |
16 |
Correct |
21 ms |
384 KB |
Output is correct |
17 |
Correct |
18 ms |
384 KB |
Output is correct |
18 |
Correct |
17 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
8 ms |
384 KB |
Output is correct |
3 |
Correct |
31 ms |
416 KB |
Output is correct |
4 |
Correct |
32 ms |
384 KB |
Output is correct |
5 |
Correct |
24 ms |
384 KB |
Output is correct |
6 |
Correct |
16 ms |
384 KB |
Output is correct |
7 |
Correct |
23 ms |
384 KB |
Output is correct |
8 |
Correct |
36 ms |
384 KB |
Output is correct |
9 |
Correct |
29 ms |
384 KB |
Output is correct |
10 |
Correct |
21 ms |
432 KB |
Output is correct |
11 |
Correct |
19 ms |
384 KB |
Output is correct |
12 |
Correct |
20 ms |
384 KB |
Output is correct |
13 |
Correct |
19 ms |
472 KB |
Output is correct |
14 |
Correct |
23 ms |
384 KB |
Output is correct |
15 |
Correct |
33 ms |
416 KB |
Output is correct |
16 |
Correct |
21 ms |
384 KB |
Output is correct |
17 |
Correct |
18 ms |
384 KB |
Output is correct |
18 |
Correct |
17 ms |
384 KB |
Output is correct |
19 |
Correct |
396 ms |
760 KB |
Output is correct |
20 |
Correct |
487 ms |
888 KB |
Output is correct |
21 |
Correct |
301 ms |
812 KB |
Output is correct |
22 |
Correct |
384 ms |
808 KB |
Output is correct |
23 |
Correct |
308 ms |
768 KB |
Output is correct |
24 |
Correct |
290 ms |
768 KB |
Output is correct |
25 |
Correct |
278 ms |
768 KB |
Output is correct |
26 |
Correct |
288 ms |
888 KB |
Output is correct |
27 |
Correct |
264 ms |
888 KB |
Output is correct |
28 |
Correct |
259 ms |
888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1789 ms |
888 KB |
Output is correct |
2 |
Correct |
8772 ms |
1648 KB |
Output is correct |
3 |
Execution timed out |
9090 ms |
2432 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
8 ms |
384 KB |
Output is correct |
3 |
Correct |
31 ms |
416 KB |
Output is correct |
4 |
Correct |
32 ms |
384 KB |
Output is correct |
5 |
Correct |
24 ms |
384 KB |
Output is correct |
6 |
Correct |
16 ms |
384 KB |
Output is correct |
7 |
Correct |
23 ms |
384 KB |
Output is correct |
8 |
Correct |
36 ms |
384 KB |
Output is correct |
9 |
Correct |
29 ms |
384 KB |
Output is correct |
10 |
Correct |
21 ms |
432 KB |
Output is correct |
11 |
Correct |
19 ms |
384 KB |
Output is correct |
12 |
Correct |
20 ms |
384 KB |
Output is correct |
13 |
Correct |
19 ms |
472 KB |
Output is correct |
14 |
Correct |
23 ms |
384 KB |
Output is correct |
15 |
Correct |
33 ms |
416 KB |
Output is correct |
16 |
Correct |
21 ms |
384 KB |
Output is correct |
17 |
Correct |
18 ms |
384 KB |
Output is correct |
18 |
Correct |
17 ms |
384 KB |
Output is correct |
19 |
Correct |
396 ms |
760 KB |
Output is correct |
20 |
Correct |
487 ms |
888 KB |
Output is correct |
21 |
Correct |
301 ms |
812 KB |
Output is correct |
22 |
Correct |
384 ms |
808 KB |
Output is correct |
23 |
Correct |
308 ms |
768 KB |
Output is correct |
24 |
Correct |
290 ms |
768 KB |
Output is correct |
25 |
Correct |
278 ms |
768 KB |
Output is correct |
26 |
Correct |
288 ms |
888 KB |
Output is correct |
27 |
Correct |
264 ms |
888 KB |
Output is correct |
28 |
Correct |
259 ms |
888 KB |
Output is correct |
29 |
Correct |
1789 ms |
888 KB |
Output is correct |
30 |
Correct |
8772 ms |
1648 KB |
Output is correct |
31 |
Execution timed out |
9090 ms |
2432 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |