#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. Python 基础之返回值与函数使用与局部变量和全局变量locals() 和 globals()

    一.函数的返回值 return return: 自定义返回值,返回到哪里? 返回到函数的[调用处]1.return 后面可以跟上六个标准数据类型,除此之外,可以跟上 类对象,函数,如果不写return ...

  2. Java编程打开运行exe程序

    String path = "notepad.exe"; //(C:\Program Files\Tencent\QQ\Bin\qq.exe) try { Runtime runt ...

  3. sqlserver链接字符串

    string connectionStr = "Data Source=LJJ-FF\\LJJ;Initial Catalog=TestDapper;User ID=sa;Password= ...

  4. <每日一课学习笔记> "mysql为什么加了索引还是慢查询"

    long_query_time mysql判断慢查询的依据是,sql执行时间与系统参数 long_query_time 作比较,如果大于这个参数,就会将这条sql计入慢查询语句中.long_query ...

  5. 【快学springboot】在springboot中写单元测试

    前言 很多公司都有写单元测试的硬性要求,在提交代码的时候,如果单测通不过或者说单元测试各种覆盖率不达标,会被拒绝合并代码.写单元测试,也是保证代码质量的一种方式. junit单元测试 相信绝大多数的J ...

  6. URL构成及各个协议默认端口

    url的构成:一般来说,http请求都会和URL地址有关,对于url来说一般由下面5个部分构成 .协议:通常就是第一个冒号之前的内容常见协议:http,https(http+ssl),ftp,ssh, ...

  7. 越南FCK批量拿站

    关键词:inurl:detail_product.asp?lang= /FCKeditor/_samples/asp/sample01.asp/FCKeditor/_samples/asp/sampl ...

  8. java并发AtomicIntegerFieldUpdater

    java并发AtomicIntegerFieldUpdater 支持对象的成员变量原子操作类由AtomicIntegerFieldUpdater,AtomicLongFieldUpdater, Ato ...

  9. redis api-zset

  10. question1 赋值运算操作符

    注意的问题书上讲的很详细了 下面是代码实现,但是VS有一个问题,strcpy安全性较低,虽然可以通脱编译,但是运行会报错,提示用strcpy_s()替代,但是,这里用strcpy()替代也不行, // ...