Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int q;
  8. cin>>q;
  9. while(q--){
  10. int b,g;
  11. cin>>b>>g;
  12.  
  13.  
  14. int arr[b+1]={0};
  15. while(g--){
  16. int q,e;
  17. cin>>q>>e;
  18. arr[e]++;
  19. }
  20. int ans=0;
  21. int temp=0;
  22. for(int i=1;i<=b;i++){
  23. temp=0;
  24. for(int j=1;j<=b;j++){
  25. if(arr[j]>=i)temp++;
  26. }
  27. ans=max(ans,temp+i);
  28. }
  29.  
  30.  
  31. cout<<ans<<endl;
  32. }
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement