Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long LL;
- typedef long double ld;
- string h;
- int n,R;
- int poi[100009];
- set<pair<int,int>> sr;
- int main()
- {
- int t;
- cin>>t;
- while(t--){
- sr.clear();
- int n,q;
- cin>>n>>q;
- int lw,ans;
- lw=ans=0;
- lw=1;
- memset(poi,0,sizeof poi);
- for(int i=0;i<n;i++)sr.insert({0,-1*(i+1)});
- for(int i=0;i<q;i++)
- {
- int x,y;
- scanf("%d%d",&x,&y);
- sr.erase({poi[x],-x});
- poi[x]+=y;
- sr.insert({poi[x],-x});
- auto it=sr.end();
- it--;
- if(lw!=-1*(it->second))
- {
- lw=-1*(it->second);
- ans=i+1;
- }
- }
- cout<<ans<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement