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 现在发现做题要把样例抄下来,然后画一画,这样才容易发现新大陆.嗯,以后做题就这样. 如果排除了被删除了的人,那么 ...
随机推荐
- 表格中td限宽溢出以省略号代替
table.ms-listviewtable { table-layout:fixed; width: 100%; } table.ms-listviewtable td[role="gri ...
- 常见Http状态码大全详解
HTTP状态码的分类 HTTP状态码由三个十进制数字组成,第一个十进制数字定义了状态码的类型,后两个数字没有分类的作用.HTTP状态码共分为5种类型: 具体如下: 状态码 内容 详细内容 信息告知 - ...
- 题解 P3950 【部落冲突】
树链剖分吼啊 一看就看出是LCT模板题啦 前记 见这么多人写LCT,却很少人写树链剖分,于是我就来一发树链剖分(其实是因为自己不会LCT) 本蒟蒻的写法和诸位写树链剖分的大神有点不同 思路 树链剖分, ...
- 【快学springboot】6.WebMvcConfigurer配置静态资源和解决跨域
勘误 有个朋友说:为什么我配置了WebMvcConfigurer,静态资源static依然能访问?! 这里是本人的失误,我在启动类中添加了EnableWebMvc注解(文章里却没有提及,最好的做法是放 ...
- reactor---元数据驱动的表单
class NameForm extends React.Component { constructor(props) { super(props); this.state = { ...
- react 开发 vscode需要安装的开发插件
1.npm Intellisense 有自动补全的功能 var lodash = require('lodash') 2. path Intellisense 自动补全文件名 import C ...
- 第2节 storm实时看板案例:9、实时看板综合案例
=================================== 10.实时看板案例 10.1 项目需求梳理 根据订单mq,快速计算双11当天的订单量.销售金额.
- Iptables与LVS——从入门到放弃
防火墙什么是防火墙?防火墙其实就是一个隔离的工具,工作于主机或者网络的边缘,对于进出本主机或者网络的报文根据事先定义好的网络规则做匹配监测.防火墙可以简单地划分为两大类:主机防火墙 网络防火墙 ...
- threading 多线程
# coding:utf- import time from threading import Thread def foo(x):#这里可以带参数def foo(x) print "foo ...
- java环境变量修改后不生效
修改java环境变量后,cmd查看java版本,还是之前的版本,需要做以下处理: 1. 删除C:\Windows\System32目录下的相关的java.exe.javaw.exe.javaws.ex ...