Advertisement
Guest User

Untitled

a guest
Oct 20th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <set>
  4. using namespace std;
  5. struct data{
  6. int a,b,no;
  7. bool operator < (const data & s)const{
  8. if(a==s.a&&b==s.b) return no>s.no;
  9. if(a==s.a) return b>s.b;
  10. return a<s.a;
  11. }
  12. }d[100005];
  13. int main(){
  14. ios::sync_with_stdio(false);
  15. int t,p,i,n,m;
  16. cin>>n>>m;
  17. set<data> team;
  18. for(i=1;i<=n;i++)
  19. d[i].no=i;
  20. while(m--){
  21. cin>>t>>p;
  22. if(t!=1&&!(d[t]<d[1])) team.erase(d[t]);
  23. d[t].b+=p;
  24. d[t].a++;
  25.  
  26. if(t!=1&&!(d[t]<d[1])) team.insert(d[t]);
  27.  
  28. if(t==1){
  29. while(!team.empty()&&*team.begin()<d[1])
  30. team.erase(team.begin());
  31. }
  32.  
  33. cout<<team.size()+1<<endl;
  34. }
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement