답안 #736659

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
736659 2023-05-06T04:50:24 Z JellyTheOctopus Exhibition (JOI19_ho_t2) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
using namespace std;

#define f first
#define s second

int N, M;
vector<pair<int, int>> pictures;
vector<int> frames;

bool check(int x) {
	int high = N-1;
	int low = 0;
	while (low < high) {
		int mid = (low+high)/2;
		int j = mid;
		int k = M-1;
		int ans = 0;
		while ((j >= 0) && (k >= 0)) {
			bool flag = false;
			while (pictures[j].s > frames[k]) {
				j--;
				if (j < 0) {
					flag = true;
					break;
				}
			}
			if (flag) break;
			ans++;
			j--;
			k--;
		}
		if (ans >= x) {
			return true;
		}
		else {
			high = mid-1;
		}
	}
	return false;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> N >> M;
	pictures.resize(N);
	frames.resize(M);
	for (int i = 0; i < N; i++) {
		cin >> pictures[i].s >> pictures[i].f;
	}
	for (int i = 0; i < M; i++) {
		cin >> frames[i];
	}
	sort(pictures.begin(), pictures.end());
	sort(frames.begin(), frames.end());
	int high = min(N, M);
	int low = 0;
	while (low < high) {
		int mid = (low+high+1)/2;
		if (check(mid)) {
			low = mid;
		}
		else {
			high = mid-1;
		}
	}
	cout << low << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -