我 P6565 [NOI Online #3 入门组]最急救助(民间数据)只有80分,这是为什么?
请大佬帮忙查一下错,谢谢!
#include<bits/stdc++.h>
using namespace std;
int n,maxn=0,sum=0,tot=0,kkk[10005];
string s[1005],sos,maxs;
struct node{
int pas;
int name;
}a[10005];
bool cmd(node x,node y)
{
return x.pas>=y.pas;
}
int main()
{
//freopen("save.in","r",stdin);
//freopen("save.out","w",stdout);
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>s[i]>>sos;
a[i].name=i;
sum=0;
while(sos.size())
{
if(sos.find("sos")==0) sum++;
sos.erase(0,1);
}
tot++;
//cout<<sum<<endl;
a[tot].pas=sum;
}
tot=1;
sort(a+1,a+n+1,cmd);
maxn=a[1].pas;
while(tot<=n&&a[tot].pas==maxn)
{
kkk[a[tot].name]=1;
tot++;
}
for(int i=1;i<=n;i++)
{
if(kkk[i]==1) cout<<s[i]<<" ";
}
cout<<endl<<maxn<<endl;
return 0;
}