답안 #744457

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
744457 2023-05-18T15:10:42 Z MODDI Exhibition (JOI19_ho_t2) C++14
100 / 100
351 ms 6580 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
int n, m;
vector<pll> arr;
vl frame;
bool can(int x){
	int j = 1, prev = 0;
	priority_queue<int, vector<int>, greater<int>> pq;
	for(int i = m-x+1; i <= m; i++){
		while(j <= n && arr[j].first <= frame[i]){
			pq.push(arr[j].second);
			j++;
		}
		if(pq.empty())	return false;
		else{
			while(!pq.empty() && (pq.top() < prev)){
				pq.pop();
			}
			if(pq.empty())	return false;
			else{
				prev = pq.top();
				pq.pop();
			}
		}
	}
	return true;
}
int main(){
	cin>>n>>m;
	arr.resize(n+1);
	frame.resize(m+1);
	for(int i = 1; i <= n; i++){
		cin>>arr[i].first>>arr[i].second;
	}
	for(int i = 1; i <= m; i++){
		cin>>frame[i];
	}
	sort(frame.begin(), frame.end());
	sort(arr.begin(), arr.end());
	int l = 1, r = min(n, m), ans = 0;
	while(l <= r){
		int mid = (l + r) / 2;
		bool can1 = can(mid);
		if(can1){
			ans = mid;
			l = mid + 1;
		}
		else
			r = mid - 1;
	}
	cout<<ans<<endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 292 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 296 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 292 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 296 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 3 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 3 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 3 ms 340 KB Output is correct
27 Correct 2 ms 316 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 2 ms 308 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 3 ms 308 KB Output is correct
32 Correct 2 ms 312 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 3 ms 332 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 3 ms 340 KB Output is correct
37 Correct 3 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 292 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 296 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 3 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 3 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 3 ms 340 KB Output is correct
27 Correct 2 ms 316 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 2 ms 308 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 3 ms 308 KB Output is correct
32 Correct 2 ms 312 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 3 ms 332 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 3 ms 340 KB Output is correct
37 Correct 3 ms 340 KB Output is correct
38 Correct 206 ms 5820 KB Output is correct
39 Correct 195 ms 5828 KB Output is correct
40 Correct 267 ms 5948 KB Output is correct
41 Correct 223 ms 5824 KB Output is correct
42 Correct 155 ms 5452 KB Output is correct
43 Correct 122 ms 5436 KB Output is correct
44 Correct 261 ms 6204 KB Output is correct
45 Correct 339 ms 6076 KB Output is correct
46 Correct 278 ms 6088 KB Output is correct
47 Correct 321 ms 5580 KB Output is correct
48 Correct 277 ms 5584 KB Output is correct
49 Correct 247 ms 4920 KB Output is correct
50 Correct 203 ms 4944 KB Output is correct
51 Correct 128 ms 5456 KB Output is correct
52 Correct 144 ms 5440 KB Output is correct
53 Correct 135 ms 5440 KB Output is correct
54 Correct 258 ms 6580 KB Output is correct
55 Correct 168 ms 5824 KB Output is correct
56 Correct 88 ms 4144 KB Output is correct
57 Correct 49 ms 1960 KB Output is correct
58 Correct 93 ms 4652 KB Output is correct
59 Correct 125 ms 4784 KB Output is correct
60 Correct 44 ms 1960 KB Output is correct
61 Correct 140 ms 3476 KB Output is correct
62 Correct 301 ms 5948 KB Output is correct
63 Correct 329 ms 5944 KB Output is correct
64 Correct 345 ms 5944 KB Output is correct
65 Correct 339 ms 5972 KB Output is correct
66 Correct 351 ms 6080 KB Output is correct
67 Correct 351 ms 6040 KB Output is correct
68 Correct 326 ms 5944 KB Output is correct
69 Correct 331 ms 5948 KB Output is correct
70 Correct 332 ms 5976 KB Output is correct
71 Correct 310 ms 5928 KB Output is correct
72 Correct 287 ms 5940 KB Output is correct
73 Correct 287 ms 5948 KB Output is correct