题意:有n个区间[ai,bi],然后有n个人落在[ci,di],每个人能用ki次。问一种方式站满n个区间。

两种区间都用先x后y的升序排序。对于当前的区间[ai,bi],将ci值小于当前ai的全部放入multiset。再lower_bound查第一个>=bi的就是答案。

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <cassert>
using namespace std;
const double EPS=1e-;
const int SZ=,INF=0x7FFFFFFF;
typedef long long lon;
struct nd{
int a,b,k,id;
bool operator<(const nd&rbs)const
{
if(a!=rbs.a)return a<rbs.a;
else return b<rbs.b;
}
}; struct cmp{
bool operator()(const nd&x,const nd&y)const
{
return x.b<y.b;
}
}; int ans[SZ]; int main()
{
std::ios::sync_with_stdio();
//freopen("d:\\1.txt","r",stdin);
int n;
cin>>n;
vector<nd> vct;
for(int i=;i<n;++i)
{
nd tmp;
cin>>tmp.a>>tmp.b;
tmp.id=i;
vct.push_back(tmp);
}
sort(vct.begin(),vct.end());
int m;
cin>>m;
vector<nd> peo;
for(int i=;i<m;++i)
{
nd tmp;
cin>>tmp.a>>tmp.b>>tmp.k;
tmp.id=i+;
peo.push_back(tmp);
}
sort(peo.begin(),peo.end());
multiset<nd,cmp> st;
bool ok=;
vector<int> res;
for(int i=,j=;i<vct.size();++i)
{
nd cur=vct[i];
for(;j<peo.size();++j)
{
if(peo[j].a<=cur.a)
{
st.insert(peo[j]);
}
else break;
}
vector<nd> mvd;
//cout<<"sz: "<<st.size()<<endl;
for(;!st.empty();)
{
if(st.lower_bound(cur)==st.end())
{
ok=;
break;
}
auto it=st.lower_bound(cur);
nd top=*it;
//cout<<" "<<i<<" "<<top.id<<" "<<top.k<<endl;
st.erase(it);
--top.k;
if(top.k>=)
{
st.insert(top);
}
else continue;
res.push_back(top.id);
ans[cur.id]=top.id;
break; }
}//
if(ok&&n==res.size())
{
cout<<"YES"<<endl;
for(int i=;i<res.size();++i)
{
if(i)cout<<" ";
cout<<ans[i];
}
cout<<endl;
}
else cout<<"NO"<<endl;
return ;
}

codeforces 497c//Distributing Parts// Codeforces Round #283(Div. 1)的更多相关文章

  1. 暴力+构造 Codeforces Round #283 (Div. 2) C. Removing Columns

    题目传送门 /* 题意:删除若干行,使得n行字符串成递增排序 暴力+构造:从前往后枚举列,当之前的顺序已经正确时,之后就不用考虑了,这样删列最小 */ /*********************** ...

  2. 构造+暴力 Codeforces Round #283 (Div. 2) B. Secret Combination

    题目传送门 /* 构造+暴力:按照题目意思,只要10次加1就变回原来的数字,暴力枚举所有数字,string大法好! */ /************************************** ...

  3. Codeforces Round #283 (Div. 2) E. Distributing Parts 贪心+set二分

    E. Distributing Parts time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  4. Codeforces Round #283 (Div. 2) C. Removing Columns 暴力

    C. Removing Columns time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  5. Codeforces Round #283 (Div. 2) A ,B ,C 暴力,暴力,暴力

    A. Minimum Difficulty time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  6. Codeforces Round #283 Div.2 D Tennis Game --二分

    题意: 两个人比赛,给出比赛序列,如果为1,说明这场1赢,为2则2赢,假如谁先赢 t 盘谁就胜这一轮,谁先赢 s 轮则赢得整个比赛.求有多少种 t 和 s 的分配方案并输出t,s. 解法: 因为要知道 ...

  7. Codeforces Round #283 (Div. 2)

    A:暴力弄就好,怎么方便怎么来. B:我们知道最多加10次, 然后每次加1后我们求能移动的最小值,大概O(N)的效率. #include<bits/stdc++.h> using name ...

  8. codeforces 497b// Tennis Game// Codeforces Round #283(Div. 1)

    题意:网球有一方赢t球算一场,先赢s场的获胜.数列arr(长度为n)记录了每场的胜利者,问可能的t和s. 首先,合法的场景必须: 1两方赢的场数不一样多. 2赢多的一方最后一场必须赢. 3最后一场必须 ...

  9. Codeforces Round #283 (Div. 2) B. Secret Combination 暴力水题

    B. Secret Combination time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

随机推荐

  1. jQuery 批量操作checkbox

    困扰很久的问题: 如果只是 $('input[type=checkbox]').attr('checked',true);//全选 $('input[type=checkbox]').attr('ch ...

  2. tomcat启动失败问题排除及解决办法 Server Tomcat v7.0 Server at localhost failed to start.

    tomcat启动失败问题排除及解决办法 Server Tomcat v7.0 Server at localhost failed to start. 导致上面问题的原因可能有很多种,每种的解决办法都 ...

  3. web前端----Bootstrap框架

    Bootstrap介绍 Bootstrap是Twitter开源的基于HTML.CSS.JavaScript的前端框架. 它是为实现快速开发Web应用程序而设计的一套前端工具包. 它支持响应式布局,并且 ...

  4. Python Web学习笔记之TCP/IP协议原理与介绍

    HTTP.FTP.SMTP.Telnet等等协议,哦!那个HTTP协议啊就是访问网页用的那个协议啊然后那个······其实······你懂得,我们应该从实际来了解他,理解网络协议的作用与功能,然后再从 ...

  5. PHP-ThinkPHP5砍价活动相关设计

    近期我们公司项目里陆陆续续有很多为了招引新用户的活动推出,砍价的活动由我来负责,我们的项目是在微信浏览器里供用户浏览访问. 大概描述:进入砍价活动列表页选择有意向的商品,用户点击商品图片可以看到WEB ...

  6. Git 的安装步骤

    Git 的安装步骤 一.下载Git Git 的官网:https://git-scm.com/ 在 Git 的官网中点击Downloads,进入如下页面: 选择对应的操作系统,以博主为例,点击Windo ...

  7. 03: Memcached

    目录: 1.1 Memcached简介与安装 1.2 python-memcached模块天生支持集群 1.3 Memcached基本操作 1.1 Memcached简介与安装返回顶部 1.Memca ...

  8. Java DecimalFormat 用法(数字格式化)

    我们经常要将数字进行格式化,比如取2位小数,这是最常见的.Java 提供 DecimalFormat 类,帮你用最快的速度将数字格式化为你需要的样子.下面是常用的例子: import java.tex ...

  9. cogs 330. [NOI2003] 文本编辑器

    ★★★   输入文件:editor2003.in   输出文件:editor2003.out   简单对比 时间限制:2 s   内存限制:128 MB [问题描述] 很久很久以前,DOS3.x的程序 ...

  10. java命令行执行程序解决依赖外部jar包的问题

    用java命令行直接执行程序,如果这个程序需要引用外部jar包.就不能单纯用java xx来执行 如果你的jar包和程序就在一个目录: 编译 javac -cp D:\yy\yy.jar,D\xx\x ...