cf749 D. Leaving Auction
#include<bits/stdc++.h>
#define lowbit(x) x&(-x)
#define LL long long
#define N 200005
#define M 1000005
#define mod 1000000007LL
#define inf 0x7ffffffff
using namespace std;
inline int ra()
{
int x=,f=; char ch=getchar();
while (ch<'' || ch>''){if (ch=='-') f=-; ch=getchar();}
while (ch>='' && ch<=''){x=x*+ch-''; ch=getchar();}
return x*f;
}
vector<int> man[N];
int mx[N],person[N];
bool cmp(int a, int b)
{
return mx[a]<mx[b];
}
int main()
{
int n=ra();
for (int i=; i<=n; i++)
{
int a=ra(),b=ra();
man[a].push_back(b);
mx[a]=b;
person[i]=i;
}
sort(person+,person++n,cmp);
int q=ra();
while (q--)
{
set<int> leave;
int k=ra();
for (int i=; i<=k; i++)
{
int t=ra();
leave.insert(t);
}
int tmp[],num=;
tmp[]=tmp[]=;
for (int i=n; i>=; i--)
{
if (leave.count(person[i])) continue;
tmp[num++]=person[i];
if (num==) break;
}
if (man[tmp[]].size()==)
{
cout<<"0 0"<<endl;
continue;
}
if (num==)
{
int it=*lower_bound(man[tmp[]].begin(),man[tmp[]].end(),mx[tmp[]]);
printf("%d %d\n",tmp[],it);
}
else if (num==)
printf("%d %d\n",tmp[],man[tmp[]][]);
}
return ;
}
//真是尴尬了一开始,竟然觉得找个最大的就可以了2333
//没想到只是比第二大最大的大就可以,真是已经弱智了。
//第一次发现vector还可以用lower_bound玩2333
cf749 D. Leaving Auction的更多相关文章
- Leaving Auction
Leaving Auction 题目链接:http://codeforces.com/contest/749/problem/D 二分 本来以为是哪种神奇的数据结构,没想到sort+lower_bon ...
- Codeforces 749D. Leaving Auction set+二分
D. Leaving Auction time limit per test: 2 seconds memory limit per test:256 megabytes input:standard ...
- cf 749D Leaving Auction
Leaving Auction time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
- CF749D Leaving Auction set排序查找
CodeForces 749D. Leaving Auction 传送门 There are n people taking part in auction today. The rules of a ...
- Codeforces 749D:Leaving Auction(set+二分)
http://codeforces.com/contest/749/problem/D 题意:有几个人在拍卖场竞价,一共有n次喊价,有q个询问,每一个询问有一个num,接下来num个人从这次拍卖中除去 ...
- CodeForces 749D Leaving Auction
二分查找,$set$. 对于某一次询问,如果把人删光了,那么输出$0$ $0$. 如果只剩下$1$个人,那么输出那个人喊的最低价格. 如果剩下的人数有大于等于两个, 这时最底下出现的情景必然是红色部分 ...
- Leaving Auction CF 749D
题目:http://codeforces.com/problemset/problem/749/D 题目大意: 有n个人竞拍,也有n个叫牌,一个人可以有多个叫价牌,但也可能有一些人根本不叫价 每个叫牌 ...
- CF749D Leaving Auction
题目链接: http://codeforces.com/problemset/problem/749/D 题目大意: 一场拍卖会,共n个买家.这些买家共出价n次,有的买家可能一次都没有出价.每次出价用 ...
- D. Leaving Auction 一题很好的思维题
http://codeforces.com/contest/749/problem/D 现在发现做题要把样例抄下来,然后画一画,这样才容易发现新大陆.嗯,以后做题就这样. 如果排除了被删除了的人,那么 ...
随机推荐
- 读取json文件
//读取json文件 var obji = File.ReadAllText(@"E:\test.json"); var resultdata = JsonConvert.Dese ...
- Django(二十)下拉列表-省市联动实例:jquery的ajax处理前端
一.知识点 1.jquery的ajax请求写法 <script src="/static/js/jquery-1.12.4.min.js"></script> ...
- Date.parse在IE/Firefox下有兼容性问题
原因: IE和Firefox是不支持含有'-'字符的日期格式,如:"2018-11-23" 解决方法: 日期格式 'yyyy-mm-dd' 改成 'yyyy/mm/dd' 代码: ...
- Keras入门——(6)长短期记忆网络LSTM(三)
参考: https://blog.csdn.net/u012735708/article/details/82769711 https://zybuluo.com/hanbingtao/note/58 ...
- Linux文件系统层次结构标准FHS
文件系统层次结构标准(英语:Filesystem Hierarchy Standard,FHS)定义了Linux操作系统中的主要目录及目录内容.FHS由Linux基金会维护. 当前版本为3.0版,于2 ...
- Mac OS 下升级gcc遇到的坑
为了升级gcc,原来版本是4.8,想升级到4.9,因为在Mac上安装cocoNLP一直出错,想试试看是不是gcc版本太低的原因,因此在此想要升级到4.9 经历了三个问题: - brew update太 ...
- mysql8.0 for windows环境配置
1.安装 zip压缩包解压后,需要设置环境变量. MYSQL_HOME = E:\mysql-8.0.16-winx64 在path中,增加变量%MYSQL_HOME%\bin 2.初始化 在安装根目 ...
- Linux centosVMware shell脚本中的逻辑判断、文件目录属性判断、if特殊用法、case判断
一.shell脚本中的逻辑判断 格式1:if 条件 ; then 语句; fi 格式2:if 条件; then 语句; else 语句; fi 格式3:if …; then … ;elif …; th ...
- java学习-初级入门-面向对象②-面向对象概述-面向对象程序设计
我们在 面向对象①中学习了,结构化程序设计. 今天我们一起学习面向对象程序设计. 学习面向对象程序设计就要了解,在面向对象中重要的知识点. 继承 . 多态 . 抽象 . 接口 我们会在接下 ...
- stm32_f103使用gcc编译的环境下printf打印函数的实现
前记 gcc编译使用的printf打印函数需要的底层函数是和其他编译器不同的,以前的是无法使用的,这里有两种方法,一种是使用gcc库里面的printf函数,自己实现底层IO函数_write.另外一 ...