이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int const N = 1e5 + 5;
typedef pair<int, int> pii;
pii pic[N];
int c[N], n, m;
bool check(int x){
int idx = 0;
priority_queue<int, vector<int>, greater<int> > pq;
int last = 0;
for(int i = x - 1; i >= 0; i--){
while(idx < n && pic[idx].first <= c[i]){
if(pic[idx].second >= last)
pq.push(pic[idx].second);
idx++;
}
if(pq.empty()){
return 0;
}
last = pq.top();
pq.pop();
}
return 1;
}
int main(){
cin >> n >> m;
for(int i = 0; i < n; i++){
cin >> pic[i].first >> pic[i].second;
}
for(int i = 0; i < m; i++){
cin >> c[i];
}
sort(pic, pic + n);
sort(c, c + m);
reverse(c, c + m);
int l = 0, r = n;
while(l < r){
int mid = l + r + 1 >> 1;
if(check(mid)){
l = mid;
}else{
r = mid - 1;
}
}
cout << l << '\n';
}
컴파일 시 표준 에러 (stderr) 메시지
joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:40:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
40 | int mid = l + r + 1 >> 1;
| ~~~~~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |