题目链接:http://codeforces.com/gym/101572/attachments
题目大意:n个队伍比赛,给出m轮过题队伍的号码以及罚时,求team1的每轮的实时排名。
思路:用multiset的结构体维护排名即可。
AC代码:
#include<bits/stdc++.h>
using namespace std;
struct node
{
int guoti;
int fashi;
bool operator<(const node &a)const
{
if(guoti==a.guoti)
return fashi<a.fashi;
return guoti>a.guoti;
}
};
multiset<node>se;
node a[100010];
int main()
{
int n,m;
for(int i=1;i<=100000;i++){
a[i].guoti=0;
a[i].fashi=0;
}
cin>>n>>m;
for(int i=0;i<m;i++)
{
int t,p;
cin>>t>>p;
if(t==1)
{
a[1].guoti++;
a[1].fashi+=p;
}
else{
if(a[t]<a[1]){
se.erase(se.find(a[t]));
}
a[t].guoti++;
a[t].fashi+=p;
se.insert(a[t]);
}
while(!se.empty()&&!(*--se.end()<a[1]))
{
se.erase(--se.end());
}
cout<<se.size()+1<<endl;
}
return 0;
}
/*
3 4
2 7
3 5
1 6
1 9
*/