Submission #812973

# Submission time Handle Problem Language Result Execution time Memory
812973 2023-08-07T12:26:03 Z SlavicG Bubble Sort 2 (JOI18_bubblesort2) C++17
38 / 100
9000 ms 2388 KB
#include "bubblesort2.h"
#include <bits/stdc++.h>
using namespace std;

std::vector<int> countScans(vector<int> a, vector<int> X, vector<int> V){
	int n = a.size();
	int q = X.size();
	vector<int> ans(q);
	vector<int> cnt(n, 0);
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < i; ++j) {
			if(a[j] > a[i]) ++cnt[i];
		}
	}
	for(int k = 0; k < q; ++k) {
		int i = X[k];
		for(int j = i + 1; j < n; ++j) {
			if(a[i] > a[j]) --cnt[j];
		}
		a[i] = V[k];
		for(int j = i + 1; j < n; ++j) {
			if(a[i] > a[j]) ++cnt[j];
		}
		cnt[i] = 0;
		for(int j = 0; j < i; ++j) {
			if(a[j] > a[i]) ++cnt[i];
		}
		int mx = *max_element(cnt.begin(), cnt.end());
		ans[k] = mx;
	}
	return ans;
}
/*
4 2
1 2 3 4
0 3
2 1
*/
# Verdict Execution time Memory Grader output
1 Correct 3 ms 212 KB Output is correct
2 Correct 5 ms 340 KB Output is correct
3 Correct 26 ms 400 KB Output is correct
4 Correct 26 ms 396 KB Output is correct
5 Correct 20 ms 392 KB Output is correct
6 Correct 13 ms 340 KB Output is correct
7 Correct 17 ms 340 KB Output is correct
8 Correct 18 ms 340 KB Output is correct
9 Correct 20 ms 340 KB Output is correct
10 Correct 16 ms 400 KB Output is correct
11 Correct 15 ms 396 KB Output is correct
12 Correct 16 ms 312 KB Output is correct
13 Correct 14 ms 340 KB Output is correct
14 Correct 14 ms 340 KB Output is correct
15 Correct 17 ms 392 KB Output is correct
16 Correct 12 ms 400 KB Output is correct
17 Correct 14 ms 400 KB Output is correct
18 Correct 12 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 212 KB Output is correct
2 Correct 5 ms 340 KB Output is correct
3 Correct 26 ms 400 KB Output is correct
4 Correct 26 ms 396 KB Output is correct
5 Correct 20 ms 392 KB Output is correct
6 Correct 13 ms 340 KB Output is correct
7 Correct 17 ms 340 KB Output is correct
8 Correct 18 ms 340 KB Output is correct
9 Correct 20 ms 340 KB Output is correct
10 Correct 16 ms 400 KB Output is correct
11 Correct 15 ms 396 KB Output is correct
12 Correct 16 ms 312 KB Output is correct
13 Correct 14 ms 340 KB Output is correct
14 Correct 14 ms 340 KB Output is correct
15 Correct 17 ms 392 KB Output is correct
16 Correct 12 ms 400 KB Output is correct
17 Correct 14 ms 400 KB Output is correct
18 Correct 12 ms 340 KB Output is correct
19 Correct 322 ms 668 KB Output is correct
20 Correct 420 ms 724 KB Output is correct
21 Correct 241 ms 724 KB Output is correct
22 Correct 333 ms 728 KB Output is correct
23 Correct 235 ms 696 KB Output is correct
24 Correct 234 ms 696 KB Output is correct
25 Correct 213 ms 716 KB Output is correct
26 Correct 213 ms 688 KB Output is correct
27 Correct 191 ms 684 KB Output is correct
28 Correct 197 ms 684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1403 ms 736 KB Output is correct
2 Correct 7239 ms 1552 KB Output is correct
3 Execution timed out 9070 ms 2388 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 212 KB Output is correct
2 Correct 5 ms 340 KB Output is correct
3 Correct 26 ms 400 KB Output is correct
4 Correct 26 ms 396 KB Output is correct
5 Correct 20 ms 392 KB Output is correct
6 Correct 13 ms 340 KB Output is correct
7 Correct 17 ms 340 KB Output is correct
8 Correct 18 ms 340 KB Output is correct
9 Correct 20 ms 340 KB Output is correct
10 Correct 16 ms 400 KB Output is correct
11 Correct 15 ms 396 KB Output is correct
12 Correct 16 ms 312 KB Output is correct
13 Correct 14 ms 340 KB Output is correct
14 Correct 14 ms 340 KB Output is correct
15 Correct 17 ms 392 KB Output is correct
16 Correct 12 ms 400 KB Output is correct
17 Correct 14 ms 400 KB Output is correct
18 Correct 12 ms 340 KB Output is correct
19 Correct 322 ms 668 KB Output is correct
20 Correct 420 ms 724 KB Output is correct
21 Correct 241 ms 724 KB Output is correct
22 Correct 333 ms 728 KB Output is correct
23 Correct 235 ms 696 KB Output is correct
24 Correct 234 ms 696 KB Output is correct
25 Correct 213 ms 716 KB Output is correct
26 Correct 213 ms 688 KB Output is correct
27 Correct 191 ms 684 KB Output is correct
28 Correct 197 ms 684 KB Output is correct
29 Correct 1403 ms 736 KB Output is correct
30 Correct 7239 ms 1552 KB Output is correct
31 Execution timed out 9070 ms 2388 KB Time limit exceeded
32 Halted 0 ms 0 KB -