Figure Skating(map映射的用法,string 映射到int)

37 篇文章 1 订阅
这篇博客主要介绍了如何分析花样滑冰和体操比赛中评委的公正性。通过比较预测排名与最终排名,确定评委最喜欢的选手。如果某选手在最终排名中提升最多,则被认为是评委的最爱。若所有选手排名未提升,系统会标记为“suspicious”。程序通过读取输入,计算每个选手的排名变化,并找出关键选手。
摘要由CSDN通过智能技术生成

链接:https://ac.nowcoder.com/acm/contest/13926/E
来源:牛客网

Figure skating 花样滑冰
gymnastics 体操
execute 执行
contestant 参赛者

Olympics observers from the Bookmakers’ Association for the Prevention of Cheating are tasked with assessing the objectivity of the jury. They will compare the predicted ranking of the contestants with the fifinal outcome to determine who is the jury’s favourite. The favourite is the contestant who rose the most places between the predicted and fifinal scoreboard. Ties are broken by whoever ends up higher on the fifinal scoreboard. However, if no one did better than predicted, this raises some red flflags with the observers, which is declared “suspicious”.

排名上升最多的就是 要找的那个人

如果没有,“suspicious”.

#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,a,b) for(int i=a;i<=b;++i)
using namespace std;

string arr[1010];
map<string, int> mp;

void solve()
{
    int n;
    cin >> n;
    rep(i,1,n)
    {
        cin >> arr[i];
        mp[arr[i]] = i; // 记录对应的位置
    }
    
    int ans = 0;
    string str;
    rep(i,1,n)
    {
        string s;
        cin >> s;
        if(mp[s]-i>ans){
            ans = mp[s]-i;
            str = s;
        }
    }
    if(ans) cout << str << endl;
    else puts("suspicious");
    
}

int main()
{
    ios;
    solve();
    return 0;
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值