1. #include<bits/stdc++.h>
  2. #define lowbit(x) x&(-x)
  3. #define LL long long
  4. #define N 200005
  5. #define M 1000005
  6. #define mod 1000000007LL
  7. #define inf 0x7ffffffff
  8. using namespace std;
  9. inline int ra()
  10. {
  11. int x=,f=; char ch=getchar();
  12. while (ch<'' || ch>''){if (ch=='-') f=-; ch=getchar();}
  13. while (ch>='' && ch<=''){x=x*+ch-''; ch=getchar();}
  14. return x*f;
  15. }
  16. vector<int> man[N];
  17. int mx[N],person[N];
  18. bool cmp(int a, int b)
  19. {
  20. return mx[a]<mx[b];
  21. }
  22. int main()
  23. {
  24. int n=ra();
  25. for (int i=; i<=n; i++)
  26. {
  27. int a=ra(),b=ra();
  28. man[a].push_back(b);
  29. mx[a]=b;
  30. person[i]=i;
  31. }
  32. sort(person+,person++n,cmp);
  33. int q=ra();
  34. while (q--)
  35. {
  36. set<int> leave;
  37. int k=ra();
  38. for (int i=; i<=k; i++)
  39. {
  40. int t=ra();
  41. leave.insert(t);
  42. }
  43. int tmp[],num=;
  44. tmp[]=tmp[]=;
  45. for (int i=n; i>=; i--)
  46. {
  47. if (leave.count(person[i])) continue;
  48. tmp[num++]=person[i];
  49. if (num==) break;
  50. }
  51. if (man[tmp[]].size()==)
  52. {
  53. cout<<"0 0"<<endl;
  54. continue;
  55. }
  56. if (num==)
  57. {
  58. int it=*lower_bound(man[tmp[]].begin(),man[tmp[]].end(),mx[tmp[]]);
  59. printf("%d %d\n",tmp[],it);
  60. }
  61. else if (num==)
  62. printf("%d %d\n",tmp[],man[tmp[]][]);
  63. }
  64. return ;
  65. }
  66. //真是尴尬了一开始,竟然觉得找个最大的就可以了2333
  67. //没想到只是比第二大最大的大就可以,真是已经弱智了。
  68. //第一次发现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. 表格中td限宽溢出以省略号代替

    table.ms-listviewtable { table-layout:fixed; width: 100%; } table.ms-listviewtable td[role="gri ...

  2. 常见Http状态码大全详解

    HTTP状态码的分类 HTTP状态码由三个十进制数字组成,第一个十进制数字定义了状态码的类型,后两个数字没有分类的作用.HTTP状态码共分为5种类型: 具体如下: 状态码 内容 详细内容 信息告知 - ...

  3. 题解 P3950 【部落冲突】

    树链剖分吼啊 一看就看出是LCT模板题啦 前记 见这么多人写LCT,却很少人写树链剖分,于是我就来一发树链剖分(其实是因为自己不会LCT) 本蒟蒻的写法和诸位写树链剖分的大神有点不同 思路 树链剖分, ...

  4. 【快学springboot】6.WebMvcConfigurer配置静态资源和解决跨域

    勘误 有个朋友说:为什么我配置了WebMvcConfigurer,静态资源static依然能访问?! 这里是本人的失误,我在启动类中添加了EnableWebMvc注解(文章里却没有提及,最好的做法是放 ...

  5. reactor---元数据驱动的表单

    class NameForm extends React.Component {  constructor(props) {    super(props);    this.state = {    ...

  6. react 开发 vscode需要安装的开发插件

    1.npm Intellisense  有自动补全的功能    var lodash = require('lodash') 2. path Intellisense 自动补全文件名 import C ...

  7. 第2节 storm实时看板案例:9、实时看板综合案例

    =================================== 10.实时看板案例 10.1 项目需求梳理 根据订单mq,快速计算双11当天的订单量.销售金额.

  8. Iptables与LVS——从入门到放弃

    防火墙什么是防火墙?防火墙其实就是一个隔离的工具,工作于主机或者网络的边缘,对于进出本主机或者网络的报文根据事先定义好的网络规则做匹配监测.防火墙可以简单地划分为两大类:主机防火墙 网络防火墙     ...

  9. threading 多线程

    # coding:utf- import time from threading import Thread def foo(x):#这里可以带参数def foo(x) print "foo ...

  10. java环境变量修改后不生效

    修改java环境变量后,cmd查看java版本,还是之前的版本,需要做以下处理: 1. 删除C:\Windows\System32目录下的相关的java.exe.javaw.exe.javaws.ex ...