zoukankan      html  css  js  c++  java
  • cf749 D. Leaving Auction

     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=0,f=1; char ch=getchar();
    12     while (ch<'0' || ch>'9'){if (ch=='-') f=-1; ch=getchar();}
    13     while (ch>='0' && ch<='9'){x=x*10+ch-'0'; 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=1; 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+1,person+1+n,cmp);
    33     int q=ra();
    34     while (q--)
    35     {
    36         set<int> leave;
    37         int k=ra();
    38         for (int i=1; i<=k; i++)
    39         {
    40             int t=ra();
    41             leave.insert(t);
    42         }
    43         int tmp[2],num=0;
    44         tmp[0]=tmp[1]=0;
    45         for (int i=n; i>=1; i--)
    46         {
    47             if (leave.count(person[i])) continue;
    48             tmp[num++]=person[i];
    49             if (num==2) break;
    50         }
    51         if (man[tmp[0]].size()==0)
    52         {
    53             cout<<"0 0"<<endl;
    54             continue;
    55         }
    56         if (num==2)
    57         {
    58             int it=*lower_bound(man[tmp[0]].begin(),man[tmp[0]].end(),mx[tmp[1]]);
    59             printf("%d %d
    ",tmp[0],it);
    60         }
    61         else if (num==1)
    62             printf("%d %d
    ",tmp[0],man[tmp[0]][0]);
    63     }
    64     return 0;
    65 }
    66 //真是尴尬了一开始,竟然觉得找个最大的就可以了2333
    67 //没想到只是比第二大最大的大就可以,真是已经弱智了。
    68 //第一次发现vector还可以用lower_bound玩2333 
  • 相关阅读:
    chrome的console功能
    vue-cli · Failed to download repo vuejs-templates/webpack: connect ETIMEDOUT 13.229.188.59:443
    let const区别!
    字符串拼接事故!
    git常用的操作命令
    vue项目中利用popstate处理页面返回操作
    Mac下安装nginx并配置SSL实现Https的访问
    浏览器缓存
    HTTP相关知识点
    CORS请求
  • 原文地址:https://www.cnblogs.com/ccd2333/p/6285541.html
Copyright © 2011-2022 走看看