답안 #532852

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
532852 2022-03-04T05:34:26 Z amunduzbaev Exhibition (JOI19_ho_t2) C++17
0 / 100
1 ms 204 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);
	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 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -