题意:有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. MyBatis学习笔记(三)——优化MyBatis配置文件中的配置

    转自孤傲苍狼的博客:http://www.cnblogs.com/xdp-gacl/p/4264301.html 一.连接数据库的配置单独放在一个properties文件中 之前,我们是直接将数据库的 ...

  2. 能让程序做的事情坚决不用人来做——批量修复markdownlint MD034警告

    欢迎和大家交流技术相关问题: 邮箱: jiangxinnju@163.com 博客园地址: http://www.cnblogs.com/jiangxinnju GitHub地址: https://g ...

  3. 循环ajax请求问题

    项目开发过程碰到过这种需求:需要循环发送ajax请求,请求参数和循环索引有关.第一次实现的时候用了类似下面的方法,结果发现发送到后端的参数数据都是最后一次循环的索引 for(var i=0; i< ...

  4. 20145322 Exp5 MS08_067漏洞测试

    20145322何志威 Exp5 MS08_067漏洞测试 实验过程 kali ip:172.20.10.4 windows 2003 ip:172.20.10.2 在控制台内使用search ms0 ...

  5. js实现ajax请求

    练下手,好久没写ajax var xmlhttp=null;//创建XMLHttprequest function createXMLHttpRequest(){ if(window.ActiveXO ...

  6. duilib中edit获得鼠标焦点后右边框被覆盖

    转载:http://www.cnblogs.com/minggong/p/6457734.html 用duilib做了一个窗口,窗口内有一个供用户输入使用的是edit控件. XML中是这样写的: &l ...

  7. Python3基础 assert 断言 确保程序的正确运行条件

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  8. 分布式系统一致性协议--Paxos算法

    Paxos: Paxos算法背景介绍: Paxos算法是分布式技术大师Lamport提出的,主要目的是通过这个算法,让参与分布式处理的每个参与者逐步达成一致意见.用好理解的方式来说,就是在一个选举过程 ...

  9. P4 Tutorials Flowlet Switching

    Github链接: Exercise 2: Implementing TCP flowlet switching P4 Tutorials Flowlet Switching 最近P4社区更新了Tut ...

  10. HDU 6103 Kirinriki(尺取法)

    http://acm.hdu.edu.cn/showproblem.php?pid=6103 题意: 给出一个字符串,在其中找两串互不重叠的子串,计算它们之间的dis值,要求dis值小于等于m,求能选 ...