help too!!!
查看原帖
help too!!!
923362
AAAuc03楼主2024/8/8 20:36
#include <bits/stdc++.h>
using namespace std;
int n,m,x;
struct xxx{
    int a,b=0,me,c;
}sp[1100];
bool cmp(xxx x,xxx y)
{
    if(x.me>y.me)
    {
        return true;
    }
    else if(x.me==y.me&&x.c<y.c)
    {
        return true;
    }
    return false;
}
int main()
{
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        cin>>x;
        sp[i].a=x;
        sp[i].c=i;
    }
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        sp[x].b++;
    }
    for(int i=1;i<=m;i++)
    {
        sp[i].me=sp[i].a*sp[i].b;
    }
    sort(sp+1,sp+1+n,cmp);
    cout<<sp[1].c;
    return 0;
}

80tps

#3、#9WA

2024/8/8 20:36
加载中...