이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define mp make_pair
#define F first
#define S second
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
pair<int, int> a[n];
int b[m];
for(int i=0; i< n; i++){
int x, y;
cin >> x >> y;
a[i]=mp(x, y);
}
for(int i=0; i< m; i++){
cin >> b[i];
}
sort(b, b+m);
sort(a, a+n);
int l=0;
int r=m;
while(l<=r){
int s=(l+r)/2;
int frst=m-s;
multiset<int> st;
int w=b[frst];
int ind;
for(int i=0; i< n; i++){
if(a[i].F<=w){
st.insert(a[i].S);
}
else {
ind=i;
break;
}
}
int cur;
if(st.empty()){
r=s-1;
continue;
}
else{
cur=*st.begin();
st.erase(st.find(cur));
}
bool ok =true;
for(int i=frst+1; i< m; i++){
w=b[i];
for(int j=ind; j<n; j++){
if(a[j].F<=w){
st.insert(a[j].S);
}
else{
ind=j;
break;
}
}
if(st.empty()){
ok=false;
continue;
}
else{
if(*st.rbegin()<cur){
ok=false;
continue;
}
else{
auto ptr=st.lower_bound(cur);
st.erase(ptr);
}
}
}
if(ok){
l=s+1;
}
else{
r=s-1;
}
}
cout << max(0,l-1) << '\n';
}
컴파일 시 표준 에러 (stderr) 메시지
joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:32:13: warning: 'ind' may be used uninitialized in this function [-Wmaybe-uninitialized]
32 | int ind;
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |