답안 #532854

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
532854 2022-03-04T05:35:41 Z amunduzbaev Exhibition (JOI19_ho_t2) C++17
100 / 100
103 ms 8692 KB
#include "bits/stdc++.h"
using namespace std;

#define ar array
#define int long long

signed main(){
	ios::sync_with_stdio(0); cin.tie(0);
	
	int n, m; cin>>n>>m;
	vector<int> s(n), v(n), c(m), p(n);
	for(int i=0;i<n;i++) cin>>s[i]>>v[i], p[i] = i;
	sort(p.begin(), p.end(), [&](int i, int j){
		return (v[i] < v[j]);
	});
	
	for(int i=0, last=0;i<n;){
		int j=i;
		while(j<n && v[p[i]] == v[p[j]]) j++;
		while(i<j) v[p[i++]] = last;
		last++;
	}
	
	for(int i=0;i<m;i++){
		cin>>c[i];
	} sort(c.begin(), c.end());
	vector<int> left(n);
	for(int i=0;i<n;i++){
		left[i] = m - (int)(lower_bound(c.begin(), c.end(), s[i]) - c.begin()) - 1;
	}
	
	vector<ar<int, 2>> t(n);
	sort(p.begin(), p.end(), [&](int i, int j){
		if(v[i] != v[j]) return v[i] < v[j];
		return left[i] > left[j];
	});
	for(int i=0;i<n;i++) t[i] = {v[p[i]], left[p[i]]};
	for(int i=0;i<n;i++) v[i] = t[i][0], left[i] = t[i][1];
	auto check = [&](int k){
		int mx = 0;
		for(int i=0;i<n;i++){
			if(left[i] == -1) continue;
			int p = max(1ll, k - left[i]);
			if(p <= mx + 1) mx++;
		} return (mx >= k);
	};
	
	int l = 0, r = n;
	while(l < r){
		int m = (l + r + 1) >> 1;
		if(check(m)) l = m;
		else r = m - 1;
	}
	
	cout<<l<<"\n";
}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 316 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 316 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 324 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 328 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 328 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 324 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 316 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 324 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 328 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 328 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 324 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 72 ms 8668 KB Output is correct
39 Correct 69 ms 8684 KB Output is correct
40 Correct 53 ms 8668 KB Output is correct
41 Correct 86 ms 8628 KB Output is correct
42 Correct 56 ms 8684 KB Output is correct
43 Correct 80 ms 8692 KB Output is correct
44 Correct 103 ms 8680 KB Output is correct
45 Correct 68 ms 8672 KB Output is correct
46 Correct 69 ms 8552 KB Output is correct
47 Correct 64 ms 8056 KB Output is correct
48 Correct 60 ms 8100 KB Output is correct
49 Correct 53 ms 6560 KB Output is correct
50 Correct 45 ms 6556 KB Output is correct
51 Correct 60 ms 8680 KB Output is correct
52 Correct 59 ms 8680 KB Output is correct
53 Correct 55 ms 8612 KB Output is correct
54 Correct 63 ms 8676 KB Output is correct
55 Correct 68 ms 8644 KB Output is correct
56 Correct 44 ms 6864 KB Output is correct
57 Correct 18 ms 1988 KB Output is correct
58 Correct 37 ms 6864 KB Output is correct
59 Correct 43 ms 6844 KB Output is correct
60 Correct 17 ms 1972 KB Output is correct
61 Correct 36 ms 4424 KB Output is correct
62 Correct 71 ms 8644 KB Output is correct
63 Correct 70 ms 8672 KB Output is correct
64 Correct 70 ms 8680 KB Output is correct
65 Correct 71 ms 8644 KB Output is correct
66 Correct 68 ms 8632 KB Output is correct
67 Correct 67 ms 8676 KB Output is correct
68 Correct 69 ms 8636 KB Output is correct
69 Correct 76 ms 8676 KB Output is correct
70 Correct 67 ms 8632 KB Output is correct
71 Correct 68 ms 8644 KB Output is correct
72 Correct 69 ms 8660 KB Output is correct
73 Correct 62 ms 8680 KB Output is correct