//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2")
#include "bubblesort2.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn=500000+10;
int dp[maxn],n,q,maxa;
std::vector<int> countScans(std::vector<int> A,std::vector<int> X,std::vector<int> V){
n=A.size(),q=X.size(),maxa=0;
for(int i=0;i<n;i++){
int ted=0;
for(int j=i-1;j>=0;j--){
ted+=A[j]>A[i]?1:0;
}
dp[i]=ted;
maxa=maxa>ted?maxa:ted;
}
vector<int>ret(q);
for(int i=0;i<q;i++){
int ind=X[i],w=V[i];
for(int j=ind+1;j<n;j++){
dp[j]+=A[ind]>A[j]?-1:0;
}
dp[ind]=0;
A[ind]=w;
for(int j=ind-1;j>=0;j--){
dp[ind]+=A[j]>A[ind]?1:0;
}
for(int j=ind+1;j<n;j++){
dp[j]+=A[ind]>A[j]?1:0;
}
maxa=0;
for(int j=0;j<n;j++){
maxa=maxa>dp[j]?maxa:dp[j];
}
ret[i]=maxa;
}
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
3 ms |
348 KB |
Output is correct |
3 |
Correct |
10 ms |
348 KB |
Output is correct |
4 |
Correct |
11 ms |
348 KB |
Output is correct |
5 |
Correct |
10 ms |
548 KB |
Output is correct |
6 |
Correct |
10 ms |
456 KB |
Output is correct |
7 |
Correct |
10 ms |
600 KB |
Output is correct |
8 |
Correct |
10 ms |
348 KB |
Output is correct |
9 |
Correct |
10 ms |
548 KB |
Output is correct |
10 |
Correct |
10 ms |
348 KB |
Output is correct |
11 |
Correct |
10 ms |
344 KB |
Output is correct |
12 |
Correct |
10 ms |
344 KB |
Output is correct |
13 |
Correct |
9 ms |
344 KB |
Output is correct |
14 |
Correct |
10 ms |
512 KB |
Output is correct |
15 |
Correct |
10 ms |
348 KB |
Output is correct |
16 |
Correct |
10 ms |
348 KB |
Output is correct |
17 |
Correct |
10 ms |
696 KB |
Output is correct |
18 |
Correct |
9 ms |
540 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
3 ms |
348 KB |
Output is correct |
3 |
Correct |
10 ms |
348 KB |
Output is correct |
4 |
Correct |
11 ms |
348 KB |
Output is correct |
5 |
Correct |
10 ms |
548 KB |
Output is correct |
6 |
Correct |
10 ms |
456 KB |
Output is correct |
7 |
Correct |
10 ms |
600 KB |
Output is correct |
8 |
Correct |
10 ms |
348 KB |
Output is correct |
9 |
Correct |
10 ms |
548 KB |
Output is correct |
10 |
Correct |
10 ms |
348 KB |
Output is correct |
11 |
Correct |
10 ms |
344 KB |
Output is correct |
12 |
Correct |
10 ms |
344 KB |
Output is correct |
13 |
Correct |
9 ms |
344 KB |
Output is correct |
14 |
Correct |
10 ms |
512 KB |
Output is correct |
15 |
Correct |
10 ms |
348 KB |
Output is correct |
16 |
Correct |
10 ms |
348 KB |
Output is correct |
17 |
Correct |
10 ms |
696 KB |
Output is correct |
18 |
Correct |
9 ms |
540 KB |
Output is correct |
19 |
Correct |
113 ms |
812 KB |
Output is correct |
20 |
Correct |
145 ms |
860 KB |
Output is correct |
21 |
Correct |
145 ms |
864 KB |
Output is correct |
22 |
Correct |
145 ms |
856 KB |
Output is correct |
23 |
Correct |
144 ms |
848 KB |
Output is correct |
24 |
Correct |
145 ms |
848 KB |
Output is correct |
25 |
Correct |
144 ms |
836 KB |
Output is correct |
26 |
Correct |
140 ms |
852 KB |
Output is correct |
27 |
Correct |
135 ms |
820 KB |
Output is correct |
28 |
Correct |
135 ms |
828 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
341 ms |
792 KB |
Output is correct |
2 |
Correct |
2358 ms |
1736 KB |
Output is correct |
3 |
Correct |
5659 ms |
2576 KB |
Output is correct |
4 |
Correct |
5593 ms |
2572 KB |
Output is correct |
5 |
Correct |
5591 ms |
2580 KB |
Output is correct |
6 |
Correct |
5594 ms |
2588 KB |
Output is correct |
7 |
Correct |
5600 ms |
2588 KB |
Output is correct |
8 |
Correct |
5596 ms |
2788 KB |
Output is correct |
9 |
Correct |
5600 ms |
2576 KB |
Output is correct |
10 |
Correct |
5191 ms |
2580 KB |
Output is correct |
11 |
Correct |
5189 ms |
2656 KB |
Output is correct |
12 |
Correct |
5178 ms |
2812 KB |
Output is correct |
13 |
Correct |
5002 ms |
2900 KB |
Output is correct |
14 |
Correct |
5069 ms |
2652 KB |
Output is correct |
15 |
Correct |
5000 ms |
2644 KB |
Output is correct |
16 |
Correct |
4786 ms |
2652 KB |
Output is correct |
17 |
Correct |
4789 ms |
2640 KB |
Output is correct |
18 |
Correct |
4862 ms |
2640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
3 ms |
348 KB |
Output is correct |
3 |
Correct |
10 ms |
348 KB |
Output is correct |
4 |
Correct |
11 ms |
348 KB |
Output is correct |
5 |
Correct |
10 ms |
548 KB |
Output is correct |
6 |
Correct |
10 ms |
456 KB |
Output is correct |
7 |
Correct |
10 ms |
600 KB |
Output is correct |
8 |
Correct |
10 ms |
348 KB |
Output is correct |
9 |
Correct |
10 ms |
548 KB |
Output is correct |
10 |
Correct |
10 ms |
348 KB |
Output is correct |
11 |
Correct |
10 ms |
344 KB |
Output is correct |
12 |
Correct |
10 ms |
344 KB |
Output is correct |
13 |
Correct |
9 ms |
344 KB |
Output is correct |
14 |
Correct |
10 ms |
512 KB |
Output is correct |
15 |
Correct |
10 ms |
348 KB |
Output is correct |
16 |
Correct |
10 ms |
348 KB |
Output is correct |
17 |
Correct |
10 ms |
696 KB |
Output is correct |
18 |
Correct |
9 ms |
540 KB |
Output is correct |
19 |
Correct |
113 ms |
812 KB |
Output is correct |
20 |
Correct |
145 ms |
860 KB |
Output is correct |
21 |
Correct |
145 ms |
864 KB |
Output is correct |
22 |
Correct |
145 ms |
856 KB |
Output is correct |
23 |
Correct |
144 ms |
848 KB |
Output is correct |
24 |
Correct |
145 ms |
848 KB |
Output is correct |
25 |
Correct |
144 ms |
836 KB |
Output is correct |
26 |
Correct |
140 ms |
852 KB |
Output is correct |
27 |
Correct |
135 ms |
820 KB |
Output is correct |
28 |
Correct |
135 ms |
828 KB |
Output is correct |
29 |
Correct |
341 ms |
792 KB |
Output is correct |
30 |
Correct |
2358 ms |
1736 KB |
Output is correct |
31 |
Correct |
5659 ms |
2576 KB |
Output is correct |
32 |
Correct |
5593 ms |
2572 KB |
Output is correct |
33 |
Correct |
5591 ms |
2580 KB |
Output is correct |
34 |
Correct |
5594 ms |
2588 KB |
Output is correct |
35 |
Correct |
5600 ms |
2588 KB |
Output is correct |
36 |
Correct |
5596 ms |
2788 KB |
Output is correct |
37 |
Correct |
5600 ms |
2576 KB |
Output is correct |
38 |
Correct |
5191 ms |
2580 KB |
Output is correct |
39 |
Correct |
5189 ms |
2656 KB |
Output is correct |
40 |
Correct |
5178 ms |
2812 KB |
Output is correct |
41 |
Correct |
5002 ms |
2900 KB |
Output is correct |
42 |
Correct |
5069 ms |
2652 KB |
Output is correct |
43 |
Correct |
5000 ms |
2644 KB |
Output is correct |
44 |
Correct |
4786 ms |
2652 KB |
Output is correct |
45 |
Correct |
4789 ms |
2640 KB |
Output is correct |
46 |
Correct |
4862 ms |
2640 KB |
Output is correct |
47 |
Execution timed out |
9100 ms |
8900 KB |
Time limit exceeded |
48 |
Halted |
0 ms |
0 KB |
- |