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 现在发现做题要把样例抄下来,然后画一画,这样才容易发现新大陆.嗯,以后做题就这样. 如果排除了被删除了的人,那么 ...
随机推荐
- Celeste 机制研究
0. 简介.惯例.总论 Celeste (塞莱斯特) 是一个具有优秀手感的平台跳跃游戏. 虽然操作所使用的按键很少, 但是却有着复杂的组合机制. 在游戏实现上, Celeste 是一个锁定 60 帧 ...
- LeetCode 349,350 数组的交集
LeetCode 349: package com.lt.datastructure.Set; import java.util.ArrayList; import java.util.LinkedH ...
- 吴裕雄--天生自然HADOOP学习笔记:使用yum安装更新软件
实验目的 了解yum的原理及配置 学习软件的更新与安装 学习源代码编译安装 实验原理 1.编译安装 前面我们讲到了安装软件的方式,因为linux是开放源码的,我们可以直接获得源码,自己编译安装.例如: ...
- thymeleaf 在 html和js 中拼接字符串
一.th:text字符串和事件拼接 <span th:text="'Welcome,'+${user.name}"> <span th:text="| ...
- Linux centosVMware MySQL主从介绍、准备工作、配置主、配置从、测试主从同步
一.MySQL主从介绍 MySQL主从又叫做Replication.AB复制.简单讲就是A和B两台机器做主从后,在A上写数据,另外一台B也会跟着写数据,两者数据实时同步的 MySQL主从是基于binl ...
- rsa免密钥登陆
#第一步 生成密钥,一路回车就行 ssh-keygen -t rsa #第二步 将密钥拷贝到目标服务器上,注意双引号 ssh-copy-id -i ~/.ssh/id_rsa.pub "ro ...
- vue - 封装input
input子组件 <el-input :value="value" placeholder="请输入内容" size="small" ...
- instance与可变参数合用,多态性
public class Doubt { public static void main(String[] args) { Dog d1=new Dog(); Dog d2=new Zangao(); ...
- Lamda ForEach使用
List<User> list = new List<User>() { }, }, }, }; list.ForEach(p => Console.WriteLine( ...
- Lesson 44 Patterns of culture
What influences us from the moment of birth? Custom has not commonly been regarded as a subject of a ...