题意:有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. 获取Android设备的唯一识别码|设备号|序号|UUID

    如何获取一个能唯一标识每台Android设备的序号? 这个问题有很多答案,但是他们中的大部分只在某些情况下有效. 根据测试: 所有的设备都可以返回一个 TelephonyManager.getDevi ...

  2. 数据仓库基础(十三)Informatica workflow

    本文转载自:http://www.cnblogs.com/evencao/p/3154715.html 看了几天的Informatica ,关于infor的资料也比较少,主要的<商业智能深入浅出 ...

  3. QTQuick控件基础(1)

    一.Item QtQuick所有的可视项目都继承自Item,它定义了可视化项目所有通用特性(x\y\width\height\anchors等)具体包括 1.作为容器 2.不透明性 没有设置opaci ...

  4. 20145317《网络对抗》shellcode注入&Return-to-libc攻击深入

    20145317<网络对抗>shellcode注入&Return-to-libc攻击深入 学习任务 shellcode注入:shellcode实际是一段代码,但却作为数据发送给受攻 ...

  5. AP聚类算法

    一.算法简介 Affinity Propagation聚类算法简称AP,是一个在07年发表在Science上的聚类算法.它实际属于message-passing algorithms的一种.算法的基本 ...

  6. SqlBulkCopy Precision Error from C# Double to Sql Decimal?

    https://forums.asp.net/t/1300113.aspx?SqlBulkCopy+Precision+Error+from+C+Double+to+Sql+Decimal+ Befo ...

  7. 【第二十七章】 springboot + zipkin(brave-okhttp实现)

    本文截取自:http://blog.csdn.net/liaokailin/article/details/52077620 一.前提 1.zipkin基本知识:附8 zipkin 2.启动zipki ...

  8. java中年月日的加减法,年月的加减法使用

    本文为博主原创,未经允许不得转载: java计算两个年月日之间相差的天数: public static int daysBetween(String smdate,String bdate) thro ...

  9. 用 C# 计算 与 java 一致的unix时间戳 (长时间整形 如:1476956079961)

    背景: 调用java提供接口,需要长时间整形作为验证. 预备知识: 1. java 的 System.currentTimeMillis() 计算的长整型,是从1970年1月1日开始,截止当前的毫秒数 ...

  10. Java中的正则表达式Pattern与Matcher

    一般来说比起功能有限的String类,我们更愿意构造功能强大的正则表达式.我们可以通过Pattern 与 Matcher 来构建功能强大的正则表达式 import java.io.File; impo ...