题意:给出n个人的历史排名成绩和现在排名成绩,如果有人进步就输出进步最大的人名,否则输出"suspicious"。
思路: 1.可以结构体排序写 2.也可直接标记前后排名情况,如果没有一点改变就是可疑,否则必定有进步的人,找出进步最大者即可。
代码实现:
#include<bits/stdc++.h>
#define endl '\n'
#define null NULL
#define ll long long
#define int long long
#define pii pair<int, int>
#define lowbit(x) (x &(-x))
#define ls(x) x<<1
#define rs(x) (x<<1+1)
#define me(ar) memset(ar, 0, sizeof ar)
#define mem(ar,num) memset(ar, num, sizeof ar)
#define rp(i, n) for(int i = 0, i < n; i ++)
#define rep(i, a, n) for(int i = a; i <= n; i ++)
#define pre(i, n, a) for(int i = n; i >= a; i --)
#define IOS ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
const int way[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
using namespace std;
const int inf = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-6;
const ll mod = 1e9+7;
const int N = 2e5 + 5;
inline void read(int &x){
char t=getchar();
while(!isdigit(t)) t=getchar();
for(x=t^48,t=getchar();isdigit(t);t=getchar()) x=x*10+(t^48);
}
int n, maxx;
string s, ans;
map<string, int> bg, ed;
vector<string> vt;
signed main()
{
IOS;
cin >> n;
for(int i = 1; i <= n; i ++){
cin >> s;
bg[s] = i;
vt.push_back(s);
}
for(int i = 1; i <= n; i ++){
cin >> s;
ed[s] = i;
}
for(auto it:vt){
if(bg[it]!=ed[it]){
if(ed[it]-bg[it]<maxx){
maxx = ed[it]-bg[it];
ans = it;
}
}
}
if(!maxx) cout << "suspicious" << endl;
else cout << ans << endl;
return 0;
}