Codeforces 659B Qualifying Contest【模拟,读题】

写这道题题解的目的就是纪念一下半个小时才读懂题。。。英文一多读一读就溜号。。。
读题时还时要静下心来。。。


题目链接:

http://codeforces.com/contest/659/problem/B

题意:

给定地区及来自相应地区的人的分数,每个地区选两个分数最高的人 参加区域赛,如果选出的两个人唯一,则输出名字,否则如果还需要进行下一次比赛,输出“?”。

分析:

不唯一的情况就是第二个人和第三个人的分数相同嘛。。。排个序找一下就好了。

代码:

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
struct Node{string s; int sc;};
Node node[maxn];
int num[maxn];
vector<Node>v[maxn];
bool cmp(Node a, Node b)
{
    return a.sc >b.sc;
}
int main (void)
{
    int n, m;
    cin>>n>>m;
    string s;
    int id, score;
    for(int i = 0; i <n; i++){
        cin>>s>>id>>score;
        node[i] = (Node){s, score};
        v[id].push_back(node[i]);
        num[id]++;
    }
    for(int i = 1; i <= m; i++){
        sort(v[i].begin(), v[i].end(), cmp);
        if(v[i].size() > 2 && v[i][2].sc == v[i][1].sc) cout<<"?"<<endl;
        else cout<<v[i][0].s<<' '<<v[i][1].s<<endl;
    }
    return 0;
}

转载于:https://www.cnblogs.com/Tuesdayzz/p/5758684.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值