atcoder abc245 - e题解
whyxiexieni · · 个人记录
atcoder abc245 - e题解
题意
有 Yes,否则输出 No。
思路
当看到multiset 维护当前可用盒子的长。
标程
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
struct Node{
int x, y;
}a[N], b[N];
int n, m, ans;
multiset<int> s;
bool cmp(const Node &i, const Node &j){
return i.x > j.x;
}
int main(){
ios::sync_with_stdio(false), cin.tie(0);
cin >> n >> m;
for(int i = 1; i <= n; i++){
cin >> a[i].x;
}
for(int i = 1; i <= n; i++){
cin >> a[i].y;
}
for(int i = 1; i <= m; i++){
cin >> b[i].x;
}
for(int i = 1; i <= m; i++){
cin >> b[i].y;
}
sort(a + 1, a + n + 1, cmp);
sort(b + 1, b + m + 1, cmp);
for(int i = 1, j = 1; i <= n; i++){
for(; j <= m && b[j].x >= a[i].x; j++){
s.insert(b[j].y);
}
auto it = s.lower_bound(a[i].y);
if(it == s.end()){
cout << "No";
return 0;
}
s.erase(it);
}
cout << "Yes";
return 0;
}