답안 #551907

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
551907 2022-04-21T21:05:47 Z QwertyPi Bubble Sort 2 (JOI18_bubblesort2) C++14
38 / 100
9000 ms 8652 KB
#include "bubblesort2.h"
#include <bits/stdc++.h>

using namespace std;
const int N = 5e5 + 5, K = 1e6 + 6;
const int INF = 1e9 + 1;
typedef pair<int, int> pii;
struct BIT{
	int bit[K + 1];
	void init(int n){
		for(int i = 1; i <= n; i++){
			bit[i] = 0;
		}
	}
	void upd(int p, int v){
		while(p <= K){
			bit[p] += v;
			p += p & -p; 
		}
	}
	int qry(int p){
		int ret = 0;
		while(p){
			ret += bit[p];
			p -= p & -p;
		}
		return ret;
	}
} bit;

std::vector<int> countScans(std::vector<int> A, std::vector<int> X, std::vector<int> V){
	int n = A.size(), q = X.size();
	vector<int> ans(q);
	set<pair<int, int>> S; map<pii, int> M;
	for(int i = 0; i < n; i++) S.insert({A[i], i});
	for(int i = 0; i < q; i++) S.insert({V[i], X[i]});
	{ int idx = 0; for(auto i : S) M[i] = ++idx; }
	int k = S.size();
	for(int i = 0; i < n; i++) A[i] = M[{A[i], i}];
	for(int i = 0; i < q; i++) V[i] = M[{V[i], X[i]}];
	for(int i = 0; i < q; i++){
		A[X[i]] = V[i];
		bit.init(k);
		int a = 0;
		for(int j = 0; j < n; j++){
			a = max(a, j - bit.qry(A[j]));
			bit.upd(A[j], 1);
		}
		ans[i] = a;
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 468 KB Output is correct
2 Correct 30 ms 580 KB Output is correct
3 Correct 157 ms 880 KB Output is correct
4 Correct 154 ms 880 KB Output is correct
5 Correct 157 ms 880 KB Output is correct
6 Correct 155 ms 876 KB Output is correct
7 Correct 159 ms 876 KB Output is correct
8 Correct 154 ms 876 KB Output is correct
9 Correct 158 ms 888 KB Output is correct
10 Correct 155 ms 808 KB Output is correct
11 Correct 167 ms 812 KB Output is correct
12 Correct 162 ms 816 KB Output is correct
13 Correct 167 ms 784 KB Output is correct
14 Correct 161 ms 788 KB Output is correct
15 Correct 158 ms 788 KB Output is correct
16 Correct 179 ms 724 KB Output is correct
17 Correct 158 ms 772 KB Output is correct
18 Correct 156 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 468 KB Output is correct
2 Correct 30 ms 580 KB Output is correct
3 Correct 157 ms 880 KB Output is correct
4 Correct 154 ms 880 KB Output is correct
5 Correct 157 ms 880 KB Output is correct
6 Correct 155 ms 876 KB Output is correct
7 Correct 159 ms 876 KB Output is correct
8 Correct 154 ms 876 KB Output is correct
9 Correct 158 ms 888 KB Output is correct
10 Correct 155 ms 808 KB Output is correct
11 Correct 167 ms 812 KB Output is correct
12 Correct 162 ms 816 KB Output is correct
13 Correct 167 ms 784 KB Output is correct
14 Correct 161 ms 788 KB Output is correct
15 Correct 158 ms 788 KB Output is correct
16 Correct 179 ms 724 KB Output is correct
17 Correct 158 ms 772 KB Output is correct
18 Correct 156 ms 760 KB Output is correct
19 Correct 1888 ms 2272 KB Output is correct
20 Correct 2363 ms 2536 KB Output is correct
21 Correct 2404 ms 2548 KB Output is correct
22 Correct 2376 ms 2544 KB Output is correct
23 Correct 2354 ms 2292 KB Output is correct
24 Correct 2369 ms 2288 KB Output is correct
25 Correct 2361 ms 2256 KB Output is correct
26 Correct 2326 ms 2176 KB Output is correct
27 Correct 2454 ms 2056 KB Output is correct
28 Correct 2353 ms 2052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2166 ms 4024 KB Output is correct
2 Execution timed out 9060 ms 8652 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 468 KB Output is correct
2 Correct 30 ms 580 KB Output is correct
3 Correct 157 ms 880 KB Output is correct
4 Correct 154 ms 880 KB Output is correct
5 Correct 157 ms 880 KB Output is correct
6 Correct 155 ms 876 KB Output is correct
7 Correct 159 ms 876 KB Output is correct
8 Correct 154 ms 876 KB Output is correct
9 Correct 158 ms 888 KB Output is correct
10 Correct 155 ms 808 KB Output is correct
11 Correct 167 ms 812 KB Output is correct
12 Correct 162 ms 816 KB Output is correct
13 Correct 167 ms 784 KB Output is correct
14 Correct 161 ms 788 KB Output is correct
15 Correct 158 ms 788 KB Output is correct
16 Correct 179 ms 724 KB Output is correct
17 Correct 158 ms 772 KB Output is correct
18 Correct 156 ms 760 KB Output is correct
19 Correct 1888 ms 2272 KB Output is correct
20 Correct 2363 ms 2536 KB Output is correct
21 Correct 2404 ms 2548 KB Output is correct
22 Correct 2376 ms 2544 KB Output is correct
23 Correct 2354 ms 2292 KB Output is correct
24 Correct 2369 ms 2288 KB Output is correct
25 Correct 2361 ms 2256 KB Output is correct
26 Correct 2326 ms 2176 KB Output is correct
27 Correct 2454 ms 2056 KB Output is correct
28 Correct 2353 ms 2052 KB Output is correct
29 Correct 2166 ms 4024 KB Output is correct
30 Execution timed out 9060 ms 8652 KB Time limit exceeded
31 Halted 0 ms 0 KB -