Submission #886998

# Submission time Handle Problem Language Result Execution time Memory
886998 2023-12-13T12:10:42 Z amirhoseinfar1385 Bubble Sort 2 (JOI18_bubblesort2) C++17
60 / 100
9000 ms 5184 KB
#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 1 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 3 ms 356 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 3 ms 448 KB Output is correct
8 Correct 3 ms 348 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 3 ms 492 KB Output is correct
11 Correct 3 ms 348 KB Output is correct
12 Correct 3 ms 348 KB Output is correct
13 Correct 3 ms 348 KB Output is correct
14 Correct 3 ms 348 KB Output is correct
15 Correct 3 ms 348 KB Output is correct
16 Correct 3 ms 348 KB Output is correct
17 Correct 3 ms 348 KB Output is correct
18 Correct 4 ms 556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 3 ms 356 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 3 ms 448 KB Output is correct
8 Correct 3 ms 348 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 3 ms 492 KB Output is correct
11 Correct 3 ms 348 KB Output is correct
12 Correct 3 ms 348 KB Output is correct
13 Correct 3 ms 348 KB Output is correct
14 Correct 3 ms 348 KB Output is correct
15 Correct 3 ms 348 KB Output is correct
16 Correct 3 ms 348 KB Output is correct
17 Correct 3 ms 348 KB Output is correct
18 Correct 4 ms 556 KB Output is correct
19 Correct 31 ms 600 KB Output is correct
20 Correct 39 ms 604 KB Output is correct
21 Correct 40 ms 604 KB Output is correct
22 Correct 39 ms 684 KB Output is correct
23 Correct 39 ms 680 KB Output is correct
24 Correct 39 ms 600 KB Output is correct
25 Correct 40 ms 684 KB Output is correct
26 Correct 43 ms 852 KB Output is correct
27 Correct 41 ms 664 KB Output is correct
28 Correct 40 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 760 KB Output is correct
2 Correct 594 ms 1488 KB Output is correct
3 Correct 1423 ms 2128 KB Output is correct
4 Correct 1427 ms 2200 KB Output is correct
5 Correct 1441 ms 1996 KB Output is correct
6 Correct 1428 ms 2128 KB Output is correct
7 Correct 1438 ms 2132 KB Output is correct
8 Correct 1442 ms 1996 KB Output is correct
9 Correct 1447 ms 1996 KB Output is correct
10 Correct 1487 ms 1996 KB Output is correct
11 Correct 1494 ms 1876 KB Output is correct
12 Correct 1488 ms 2000 KB Output is correct
13 Correct 1511 ms 1996 KB Output is correct
14 Correct 1506 ms 1972 KB Output is correct
15 Correct 1528 ms 2000 KB Output is correct
16 Correct 1545 ms 2024 KB Output is correct
17 Correct 1539 ms 1996 KB Output is correct
18 Correct 1541 ms 2052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 3 ms 356 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 3 ms 448 KB Output is correct
8 Correct 3 ms 348 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 3 ms 492 KB Output is correct
11 Correct 3 ms 348 KB Output is correct
12 Correct 3 ms 348 KB Output is correct
13 Correct 3 ms 348 KB Output is correct
14 Correct 3 ms 348 KB Output is correct
15 Correct 3 ms 348 KB Output is correct
16 Correct 3 ms 348 KB Output is correct
17 Correct 3 ms 348 KB Output is correct
18 Correct 4 ms 556 KB Output is correct
19 Correct 31 ms 600 KB Output is correct
20 Correct 39 ms 604 KB Output is correct
21 Correct 40 ms 604 KB Output is correct
22 Correct 39 ms 684 KB Output is correct
23 Correct 39 ms 680 KB Output is correct
24 Correct 39 ms 600 KB Output is correct
25 Correct 40 ms 684 KB Output is correct
26 Correct 43 ms 852 KB Output is correct
27 Correct 41 ms 664 KB Output is correct
28 Correct 40 ms 600 KB Output is correct
29 Correct 71 ms 760 KB Output is correct
30 Correct 594 ms 1488 KB Output is correct
31 Correct 1423 ms 2128 KB Output is correct
32 Correct 1427 ms 2200 KB Output is correct
33 Correct 1441 ms 1996 KB Output is correct
34 Correct 1428 ms 2128 KB Output is correct
35 Correct 1438 ms 2132 KB Output is correct
36 Correct 1442 ms 1996 KB Output is correct
37 Correct 1447 ms 1996 KB Output is correct
38 Correct 1487 ms 1996 KB Output is correct
39 Correct 1494 ms 1876 KB Output is correct
40 Correct 1488 ms 2000 KB Output is correct
41 Correct 1511 ms 1996 KB Output is correct
42 Correct 1506 ms 1972 KB Output is correct
43 Correct 1528 ms 2000 KB Output is correct
44 Correct 1545 ms 2024 KB Output is correct
45 Correct 1539 ms 1996 KB Output is correct
46 Correct 1541 ms 2052 KB Output is correct
47 Execution timed out 9033 ms 5184 KB Time limit exceeded
48 Halted 0 ms 0 KB -