답안 #852925

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
852925 2023-09-23T07:38:55 Z MuntherCarrot Bubble Sort 2 (JOI18_bubblesort2) C++14
60 / 100
3785 ms 12052 KB
// by me
#include "bubblesort2.h"

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define all(x) x.begin(), x.end()

std::vector<int> countScans(std::vector<int> A, std::vector<int> X, std::vector<int> V){
	int Q = X.size();
	int N = A.size();
	vector<int> ans(Q, 0);
	if(N <= 8000){
		for(int i = 0; i < Q; i++){
			A[X[i]] = V[i];
			vector<int> f(N);
			iota(all(f), 0);
			sort(all(f), [&](int a, int b){
				return A[a] < A[b];
			});
			for(int j = 0; j < N; j++){
				ans[i] = max(ans[i], f[j] - j);
			}
		}
		return ans;
	}
	vector<set<int>> f(101);
	for(int i = 0; i < N; i++){
		f[A[i]].insert(i);
	}
	for(int i = 0; i < Q; i++){
		f[A[X[i]]].erase(X[i]);
		A[X[i]] = V[i];
		f[A[X[i]]].insert(X[i]);
		int x = 0;
		for(auto &st : f){
			if(st.empty()) continue;
			x += st.size();
			int mx = *st.rbegin();
			ans[i] = max(ans[i], mx - x + 1);
		}
	}
	return ans;
}

//
/*
int readInt(){
	int i;
	if(scanf("%d",&i)!=1){
		fprintf(stderr,"Error while reading input\n");
		exit(1);
	}
	return i;
}

int main(){
	int N,Q;
	N=readInt();
	Q=readInt();

	std::vector<int> A(N);
	for(int i=0;i<N;i++)
		A[i]=readInt();

	std::vector<int> X(Q),V(Q);
	for(int j=0;j<Q;j++){
		X[j]=readInt();
		V[j]=readInt();
	}

	std::vector<int> res=countScans(A,X,V);

	for(int j=0;j<int(res.size());j++)
		printf("%d\n",res[j]);
}
//*/
// by me
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 344 KB Output is correct
2 Correct 27 ms 600 KB Output is correct
3 Correct 193 ms 468 KB Output is correct
4 Correct 193 ms 472 KB Output is correct
5 Correct 188 ms 476 KB Output is correct
6 Correct 115 ms 348 KB Output is correct
7 Correct 157 ms 476 KB Output is correct
8 Correct 176 ms 468 KB Output is correct
9 Correct 188 ms 344 KB Output is correct
10 Correct 109 ms 472 KB Output is correct
11 Correct 103 ms 348 KB Output is correct
12 Correct 106 ms 476 KB Output is correct
13 Correct 103 ms 344 KB Output is correct
14 Correct 104 ms 348 KB Output is correct
15 Correct 103 ms 344 KB Output is correct
16 Correct 97 ms 344 KB Output is correct
17 Correct 89 ms 344 KB Output is correct
18 Correct 79 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 344 KB Output is correct
2 Correct 27 ms 600 KB Output is correct
3 Correct 193 ms 468 KB Output is correct
4 Correct 193 ms 472 KB Output is correct
5 Correct 188 ms 476 KB Output is correct
6 Correct 115 ms 348 KB Output is correct
7 Correct 157 ms 476 KB Output is correct
8 Correct 176 ms 468 KB Output is correct
9 Correct 188 ms 344 KB Output is correct
10 Correct 109 ms 472 KB Output is correct
11 Correct 103 ms 348 KB Output is correct
12 Correct 106 ms 476 KB Output is correct
13 Correct 103 ms 344 KB Output is correct
14 Correct 104 ms 348 KB Output is correct
15 Correct 103 ms 344 KB Output is correct
16 Correct 97 ms 344 KB Output is correct
17 Correct 89 ms 344 KB Output is correct
18 Correct 79 ms 348 KB Output is correct
19 Correct 2885 ms 628 KB Output is correct
20 Correct 3785 ms 668 KB Output is correct
21 Correct 3250 ms 664 KB Output is correct
22 Correct 3647 ms 660 KB Output is correct
23 Correct 2125 ms 664 KB Output is correct
24 Correct 2140 ms 664 KB Output is correct
25 Correct 2128 ms 656 KB Output is correct
26 Correct 2134 ms 660 KB Output is correct
27 Correct 2059 ms 664 KB Output is correct
28 Correct 2048 ms 660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 1884 KB Output is correct
2 Correct 30 ms 3008 KB Output is correct
3 Correct 54 ms 3932 KB Output is correct
4 Correct 53 ms 3932 KB Output is correct
5 Correct 57 ms 3928 KB Output is correct
6 Correct 53 ms 4148 KB Output is correct
7 Correct 61 ms 4188 KB Output is correct
8 Correct 53 ms 3928 KB Output is correct
9 Correct 52 ms 3932 KB Output is correct
10 Correct 45 ms 3928 KB Output is correct
11 Correct 45 ms 3932 KB Output is correct
12 Correct 50 ms 4356 KB Output is correct
13 Correct 44 ms 3932 KB Output is correct
14 Correct 49 ms 4152 KB Output is correct
15 Correct 48 ms 3916 KB Output is correct
16 Correct 39 ms 4104 KB Output is correct
17 Correct 38 ms 3984 KB Output is correct
18 Correct 40 ms 4180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 344 KB Output is correct
2 Correct 27 ms 600 KB Output is correct
3 Correct 193 ms 468 KB Output is correct
4 Correct 193 ms 472 KB Output is correct
5 Correct 188 ms 476 KB Output is correct
6 Correct 115 ms 348 KB Output is correct
7 Correct 157 ms 476 KB Output is correct
8 Correct 176 ms 468 KB Output is correct
9 Correct 188 ms 344 KB Output is correct
10 Correct 109 ms 472 KB Output is correct
11 Correct 103 ms 348 KB Output is correct
12 Correct 106 ms 476 KB Output is correct
13 Correct 103 ms 344 KB Output is correct
14 Correct 104 ms 348 KB Output is correct
15 Correct 103 ms 344 KB Output is correct
16 Correct 97 ms 344 KB Output is correct
17 Correct 89 ms 344 KB Output is correct
18 Correct 79 ms 348 KB Output is correct
19 Correct 2885 ms 628 KB Output is correct
20 Correct 3785 ms 668 KB Output is correct
21 Correct 3250 ms 664 KB Output is correct
22 Correct 3647 ms 660 KB Output is correct
23 Correct 2125 ms 664 KB Output is correct
24 Correct 2140 ms 664 KB Output is correct
25 Correct 2128 ms 656 KB Output is correct
26 Correct 2134 ms 660 KB Output is correct
27 Correct 2059 ms 664 KB Output is correct
28 Correct 2048 ms 660 KB Output is correct
29 Correct 9 ms 1884 KB Output is correct
30 Correct 30 ms 3008 KB Output is correct
31 Correct 54 ms 3932 KB Output is correct
32 Correct 53 ms 3932 KB Output is correct
33 Correct 57 ms 3928 KB Output is correct
34 Correct 53 ms 4148 KB Output is correct
35 Correct 61 ms 4188 KB Output is correct
36 Correct 53 ms 3928 KB Output is correct
37 Correct 52 ms 3932 KB Output is correct
38 Correct 45 ms 3928 KB Output is correct
39 Correct 45 ms 3932 KB Output is correct
40 Correct 50 ms 4356 KB Output is correct
41 Correct 44 ms 3932 KB Output is correct
42 Correct 49 ms 4152 KB Output is correct
43 Correct 48 ms 3916 KB Output is correct
44 Correct 39 ms 4104 KB Output is correct
45 Correct 38 ms 3984 KB Output is correct
46 Correct 40 ms 4180 KB Output is correct
47 Runtime error 40 ms 12052 KB Execution killed with signal 11
48 Halted 0 ms 0 KB -