#include "bubblesort2.h"
#include <bits/stdc++.h>
using namespace std;
int n,q;
std::vector<int> countScans(std::vector<int> a,std::vector<int> x,std::vector<int> v){
n=a.size(),q=x.size();
int b[n];
vector<int> ans(q);
for (int i=0;i<n;i++){
b[i]=0;
for (int j=0;j<i;j++) b[i]+=bool(a[j]>a[i]);
}
for (int k=0;k<q;k++){
b[x[k]]=0,ans[k]=0;
for (int i=x[k]+1;i<n;i++) if (a[i]<a[x[k]]) b[i]--;
a[x[k]]=v[k];
for (int i=0;i<x[k];i++) b[x[k]]+=bool(a[i]>a[x[k]]);
for (int i=x[k]+1;i<n;i++) b[i]+=bool(a[x[k]]>a[i]);
for (int i=0;i<n;i++) ans[k]=max(ans[k],b[i]);
//for (int i=0;i<n;i++) cout<<b[i]<<' ';
//cout<<endl;
}return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
344 KB |
Output is correct |
3 |
Correct |
13 ms |
348 KB |
Output is correct |
4 |
Correct |
13 ms |
348 KB |
Output is correct |
5 |
Correct |
11 ms |
536 KB |
Output is correct |
6 |
Correct |
11 ms |
600 KB |
Output is correct |
7 |
Correct |
12 ms |
348 KB |
Output is correct |
8 |
Correct |
13 ms |
348 KB |
Output is correct |
9 |
Correct |
15 ms |
540 KB |
Output is correct |
10 |
Correct |
10 ms |
344 KB |
Output is correct |
11 |
Correct |
10 ms |
536 KB |
Output is correct |
12 |
Correct |
10 ms |
744 KB |
Output is correct |
13 |
Correct |
9 ms |
492 KB |
Output is correct |
14 |
Correct |
9 ms |
600 KB |
Output is correct |
15 |
Correct |
10 ms |
348 KB |
Output is correct |
16 |
Correct |
9 ms |
348 KB |
Output is correct |
17 |
Correct |
9 ms |
444 KB |
Output is correct |
18 |
Correct |
9 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
344 KB |
Output is correct |
3 |
Correct |
13 ms |
348 KB |
Output is correct |
4 |
Correct |
13 ms |
348 KB |
Output is correct |
5 |
Correct |
11 ms |
536 KB |
Output is correct |
6 |
Correct |
11 ms |
600 KB |
Output is correct |
7 |
Correct |
12 ms |
348 KB |
Output is correct |
8 |
Correct |
13 ms |
348 KB |
Output is correct |
9 |
Correct |
15 ms |
540 KB |
Output is correct |
10 |
Correct |
10 ms |
344 KB |
Output is correct |
11 |
Correct |
10 ms |
536 KB |
Output is correct |
12 |
Correct |
10 ms |
744 KB |
Output is correct |
13 |
Correct |
9 ms |
492 KB |
Output is correct |
14 |
Correct |
9 ms |
600 KB |
Output is correct |
15 |
Correct |
10 ms |
348 KB |
Output is correct |
16 |
Correct |
9 ms |
348 KB |
Output is correct |
17 |
Correct |
9 ms |
444 KB |
Output is correct |
18 |
Correct |
9 ms |
348 KB |
Output is correct |
19 |
Correct |
158 ms |
604 KB |
Output is correct |
20 |
Correct |
203 ms |
860 KB |
Output is correct |
21 |
Correct |
159 ms |
856 KB |
Output is correct |
22 |
Correct |
175 ms |
868 KB |
Output is correct |
23 |
Correct |
153 ms |
824 KB |
Output is correct |
24 |
Correct |
161 ms |
828 KB |
Output is correct |
25 |
Correct |
144 ms |
816 KB |
Output is correct |
26 |
Correct |
140 ms |
812 KB |
Output is correct |
27 |
Correct |
128 ms |
824 KB |
Output is correct |
28 |
Correct |
128 ms |
828 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
401 ms |
864 KB |
Output is correct |
2 |
Correct |
3293 ms |
1684 KB |
Output is correct |
3 |
Correct |
7964 ms |
2560 KB |
Output is correct |
4 |
Correct |
7940 ms |
2556 KB |
Output is correct |
5 |
Correct |
7012 ms |
2560 KB |
Output is correct |
6 |
Correct |
7345 ms |
2568 KB |
Output is correct |
7 |
Correct |
6692 ms |
2568 KB |
Output is correct |
8 |
Correct |
6791 ms |
2564 KB |
Output is correct |
9 |
Correct |
6800 ms |
2392 KB |
Output is correct |
10 |
Correct |
4951 ms |
2652 KB |
Output is correct |
11 |
Correct |
5042 ms |
2652 KB |
Output is correct |
12 |
Correct |
4999 ms |
2644 KB |
Output is correct |
13 |
Correct |
4789 ms |
2624 KB |
Output is correct |
14 |
Correct |
4762 ms |
2628 KB |
Output is correct |
15 |
Correct |
4806 ms |
2652 KB |
Output is correct |
16 |
Correct |
4576 ms |
2624 KB |
Output is correct |
17 |
Correct |
4572 ms |
2624 KB |
Output is correct |
18 |
Correct |
4590 ms |
2620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
344 KB |
Output is correct |
3 |
Correct |
13 ms |
348 KB |
Output is correct |
4 |
Correct |
13 ms |
348 KB |
Output is correct |
5 |
Correct |
11 ms |
536 KB |
Output is correct |
6 |
Correct |
11 ms |
600 KB |
Output is correct |
7 |
Correct |
12 ms |
348 KB |
Output is correct |
8 |
Correct |
13 ms |
348 KB |
Output is correct |
9 |
Correct |
15 ms |
540 KB |
Output is correct |
10 |
Correct |
10 ms |
344 KB |
Output is correct |
11 |
Correct |
10 ms |
536 KB |
Output is correct |
12 |
Correct |
10 ms |
744 KB |
Output is correct |
13 |
Correct |
9 ms |
492 KB |
Output is correct |
14 |
Correct |
9 ms |
600 KB |
Output is correct |
15 |
Correct |
10 ms |
348 KB |
Output is correct |
16 |
Correct |
9 ms |
348 KB |
Output is correct |
17 |
Correct |
9 ms |
444 KB |
Output is correct |
18 |
Correct |
9 ms |
348 KB |
Output is correct |
19 |
Correct |
158 ms |
604 KB |
Output is correct |
20 |
Correct |
203 ms |
860 KB |
Output is correct |
21 |
Correct |
159 ms |
856 KB |
Output is correct |
22 |
Correct |
175 ms |
868 KB |
Output is correct |
23 |
Correct |
153 ms |
824 KB |
Output is correct |
24 |
Correct |
161 ms |
828 KB |
Output is correct |
25 |
Correct |
144 ms |
816 KB |
Output is correct |
26 |
Correct |
140 ms |
812 KB |
Output is correct |
27 |
Correct |
128 ms |
824 KB |
Output is correct |
28 |
Correct |
128 ms |
828 KB |
Output is correct |
29 |
Correct |
401 ms |
864 KB |
Output is correct |
30 |
Correct |
3293 ms |
1684 KB |
Output is correct |
31 |
Correct |
7964 ms |
2560 KB |
Output is correct |
32 |
Correct |
7940 ms |
2556 KB |
Output is correct |
33 |
Correct |
7012 ms |
2560 KB |
Output is correct |
34 |
Correct |
7345 ms |
2568 KB |
Output is correct |
35 |
Correct |
6692 ms |
2568 KB |
Output is correct |
36 |
Correct |
6791 ms |
2564 KB |
Output is correct |
37 |
Correct |
6800 ms |
2392 KB |
Output is correct |
38 |
Correct |
4951 ms |
2652 KB |
Output is correct |
39 |
Correct |
5042 ms |
2652 KB |
Output is correct |
40 |
Correct |
4999 ms |
2644 KB |
Output is correct |
41 |
Correct |
4789 ms |
2624 KB |
Output is correct |
42 |
Correct |
4762 ms |
2628 KB |
Output is correct |
43 |
Correct |
4806 ms |
2652 KB |
Output is correct |
44 |
Correct |
4576 ms |
2624 KB |
Output is correct |
45 |
Correct |
4572 ms |
2624 KB |
Output is correct |
46 |
Correct |
4590 ms |
2620 KB |
Output is correct |
47 |
Execution timed out |
9035 ms |
8532 KB |
Time limit exceeded |
48 |
Halted |
0 ms |
0 KB |
- |