Codeforces Round #310 (Div. 1) B. Case of Fugitive(set二分)
来源:互联网 发布:淘宝客活动广场在哪 编辑:程序博客网 时间:2024/05/18 23:53
#include <bits/stdc++.h>#define foreach(it,v) for(__typeof(v.begin()) it = v.begin(); it != v.end(); ++it)using namespace std;typedef long long ll;const int maxn = 2e5 + 10;#define x first#define y secondtypedef pair<ll,ll> pll;typedef pair<pll,ll> plll;typedef plll Seg;typedef pll Bridge;bool cmpSeg(const Seg & a, const Seg & b){pll ta = a.x, tb = b.x;if(ta.y == tb.y) return ta.x < tb.x;return ta.y < tb.y;}Seg p[maxn];Bridge a[maxn];ll l[maxn],r[maxn],ans[maxn];int main(int argc, char const *argv[]){ios_base::sync_with_stdio(false);cin.tie(0);int n,m;while(cin>>n>>m) {for(int i = 1; i <= n; i++) {cin>>l[i]>>r[i];}for(int i = 1; i < n; i++) {p[i-1].x.x = l[i+1] - r[i];p[i-1].x.y = r[i+1] - l[i];p[i-1].y = i-1;}sort(p,p+n-1,cmpSeg);set<Bridge>Q;for(int i = 1; i <= m; i++) {ll a,id = i;cin>>a;Q.insert(make_pair(a,id));}set<Bridge>::iterator it;bool ok = (m + 1 >= n);for(int i = 0; i < n-1; i++) {if(!ok) break;it = Q.lower_bound(make_pair(p[i].x.x,0LL));if(it==Q.end()||it->x > p[i].x.y) {ok = false;break;}ans[p[i].y] = it->y;Q.erase(it);}if(ok) {cout<<"Yes\n";for(int i = 0; i < n-1; i++)cout<<ans[i]<<" ";cout<<"\n";}else cout<<"No\n";}return 0;}
0 0
- Codeforces Round #310 (Div. 1) B. Case of Fugitive(set二分)
- Codeforces Round #310 (Div. 1) B. Case of Fugitive
- Codeforces Round #310 (Div. 1) B. Case of Fugitive
- Codeforces Round #310 (Div. 1) B. Case of Fugitive 贪心
- Codeforces Round #310 (Div. 2)-D. Case of Fugitive(贪心)
- codeforces #310 B B. Case of Fugitive(贪心)
- [Codeforces Round #310 DIV1B (CF555B)] Case of Fugitive
- Codeforces 555B Case of Fugitive 搭桥
- Codeforces Round #310 (Div. 2) B. Case of Fake Numbers
- cf #310 D. Case of Fugitive (二分)
- #310 (div.2) D. Case of Fugitive
- Codeforces Round #310 (Div. 1) D. Case of a Top Secret 二分 stl应用
- Codeforces 555B Case of Fugitive 排序+贪心
- Codeforces Round #310 (Div. 1) C Case of Chocolate
- B. Case of Fake Numbers( Codeforces Round #310 (Div. 2) 简单题)
- codeforces 556 D Case of Fugitive
- codeforces 556D Case of Fugitive
- 区间点覆盖 Case of Fugitive:CodeForces
- QT做类似QQ截图功能(带图片编辑功能)
- linux sed 批量替换字符串
- HDU1061 Rightmost Digit(快速幂取模)
- Android开发过程中,如何稳定高效的完成不同分辨率下的调试工作
- 关于edgesForExtendedLayout和automaticallyAdjustsScrollViewInsets
- Codeforces Round #310 (Div. 1) B. Case of Fugitive(set二分)
- VS2008 error C2664:不能将参数 2 从“const char [5]”转换为“LPCTSTR”
- Memcache和Redis区别
- Android jniLibs 里面的.so丢失
- opencl dx11
- Ubuntu-14.04下安装TinyOS-2.1.2
- Android Fragments (Android官方文档中文版)
- oracle ORA-12899错误的解决方法
- IOS 里面你没有注意到的一些小知识