#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的更多相关文章

  1. Leaving Auction

    Leaving Auction 题目链接:http://codeforces.com/contest/749/problem/D 二分 本来以为是哪种神奇的数据结构,没想到sort+lower_bon ...

  2. Codeforces 749D. Leaving Auction set+二分

    D. Leaving Auction time limit per test: 2 seconds memory limit per test:256 megabytes input:standard ...

  3. cf 749D Leaving Auction

    Leaving Auction time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  4. CF749D Leaving Auction set排序查找

    CodeForces 749D. Leaving Auction 传送门 There are n people taking part in auction today. The rules of a ...

  5. Codeforces 749D:Leaving Auction(set+二分)

    http://codeforces.com/contest/749/problem/D 题意:有几个人在拍卖场竞价,一共有n次喊价,有q个询问,每一个询问有一个num,接下来num个人从这次拍卖中除去 ...

  6. CodeForces 749D Leaving Auction

    二分查找,$set$. 对于某一次询问,如果把人删光了,那么输出$0$ $0$. 如果只剩下$1$个人,那么输出那个人喊的最低价格. 如果剩下的人数有大于等于两个, 这时最底下出现的情景必然是红色部分 ...

  7. Leaving Auction CF 749D

    题目:http://codeforces.com/problemset/problem/749/D 题目大意: 有n个人竞拍,也有n个叫牌,一个人可以有多个叫价牌,但也可能有一些人根本不叫价 每个叫牌 ...

  8. CF749D Leaving Auction

    题目链接: http://codeforces.com/problemset/problem/749/D 题目大意: 一场拍卖会,共n个买家.这些买家共出价n次,有的买家可能一次都没有出价.每次出价用 ...

  9. D. Leaving Auction 一题很好的思维题

    http://codeforces.com/contest/749/problem/D 现在发现做题要把样例抄下来,然后画一画,这样才容易发现新大陆.嗯,以后做题就这样. 如果排除了被删除了的人,那么 ...

随机推荐

  1. intelliJ IDEA 全屏键盘手

    从MyEclipse到IntelliJ IDEA --让你脱键盘,全键盘操作 从MyEclipse转战到IntelliJ IDEA的经历 我一个朋友写了一篇"从Eclipse到Android ...

  2. Django 学习之Django Rest Framework_序列化器_Serializer

    作用: 1.序列化,序列化器会把模型对象转换成字典,经过response以后变成json字符串. 2.反序列化,把客户端发送过来的数据,经过request以后变成字典,序列化器可以把字典转成模型. 3 ...

  3. 五、Centos7安装mysql:第一步查看系统有无mysql,然后删除之

    CentOS下MySQL的彻底卸载 原创 2015年10月12日 00:16:02 标签: 21149 编辑 删除 #################CentOS7下MySQL的卸载######### ...

  4. Oracle建表时主键自增

    1.创建表 /*第一步:创建表格*/ create table t_user( id int primary key, --主键,自增长 username ), password ), type ) ...

  5. Linux centosVMware su命令、sudo命令、限制root远程登录

    一.su命令 Linux系统中有些事情只有root用户才能做,普通用户不能做,这时候就需要临时切换到root身份了. [root@davery ~]# whoamiroot [root@davery ...

  6. 数据库同步和使用JSONObject让Java Bean“原地满状态复活”

    分类: [java]2013-11-28 21:04 729人阅读 评论(0) 收藏 举报 简介我为什么写这样一个简单的问题呢?首先介绍一下项目背景.最近需要做一个数据库同步的工作,也就是一个Web程 ...

  7. 图片FormData上传

    var base64String = /*base64图片串*/; //这里对base64串进行操作,去掉url头,并转换为byte var bytes = window.atob(base64Str ...

  8. 吴裕雄 Bootstrap 前端框架开发——Bootstrap 辅助类:显示和隐藏内容

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  9. mysql 子查询问题

    今天在做子查询的时候发现运行报错, 我的代码是select* from (....) device des ,我一直以为的是device是表名,然后dec是别名,后面问了同事才知道from(...)这 ...

  10. JuJu团队1月9号工作汇报

    JuJu团队1月9号工作汇报 JuJu   Scrum 团队成员 今日工作 剩余任务 困难 飞飞 将示例程序打包成exe 将crossentrophy和softmax连接起来 无 婷婷 -- 完善ma ...