이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb push_back
#define epb emplace_back
using namespace std;
const ll linf = 1e18 + 1;
int main(){
int n; cin >> n;
int m; cin >> m;
vector <ll> d(n + 1, linf);
d[0] = 0;
pll a[n + 1];
ll b[n + 1];
for(int i = 1; i <= n; i++){
cin >> a[i].f >> a[i].s;
}
for(int i= 1; i <= m; i++) cin >> b[i];
int l = 0, r = n + 1;
sort(a + 1 , a + 1 + n);
sort(b + 1, b + 1 + m);
while(l + 1 < r){
int mid = (l + r) / 2;
multiset <ll> st;
ll last = -1;
bool ind = true;
int cur = 1;
if(m < mid) {
r = mid;
continue;
}
for(int i = m - mid + 1; i <= m; i++){
while(cur <= n && a[cur].f <= b[i])
st.insert(a[cur].s), cur++;
multiset <ll> :: iterator it = st.lower_bound(last);
if(it == st.end()){
ind = false;
break;
}
last = *it;
st.erase(it);
}
if(ind) l = mid;
else r = mid;
}
cout << l;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |