Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- int main()
- {
- int q;
- cin>>q;
- while(q--){
- int b,g;
- cin>>b>>g;
- int arr[b+1]={0};
- while(g--){
- int q,e;
- cin>>q>>e;
- arr[e]++;
- }
- int ans=0;
- int temp=0;
- for(int i=1;i<=b;i++){
- temp=0;
- for(int j=1;j<=b;j++){
- if(arr[j]>=i)temp++;
- }
- ans=max(ans,temp+i);
- }
- cout<<ans<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement