Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include<cstdio>
  2. #include<cstring>
  3. #include<set>
  4. #include<algorithm>
  5.  
  6. using namespace std;
  7.  
  8. int s,br,z,sol,sol1,x,y,n,p[1000100];
  9.  
  10. struct ulaz{
  11. int q,tip;
  12. };
  13.  
  14. bool cmp(ulaz a,ulaz b){
  15.  
  16. if(a.x != b.x){
  17.  
  18. return a.x < b.x
  19. }
  20.  
  21. else{
  22.  
  23. return 0;
  24. }
  25.  
  26. }
  27.  
  28. ulaz t[1000];
  29.  
  30. int main(){
  31.  
  32. scanf("%d",&s);
  33.  
  34. for(int k = 0;k < s; k++){
  35.  
  36. sol = sol1 = 0;
  37.  
  38. n = br = 0;
  39.  
  40. scanf("%d",&z);
  41.  
  42. for(int j = 0;j < z; j++){
  43.  
  44. scanf("%d %d",&x ,&y);
  45.  
  46. t[br.q] = x;
  47.  
  48. t[br.tip] = y;
  49.  
  50. br++;
  51.  
  52. p[x] = 1;
  53.  
  54. p[y] = -1;
  55.  
  56. }
  57.  
  58. sort(t,t + br,cmp);
  59.  
  60. for(int i = 0;i <= br;i++){
  61.  
  62. sol1 = sol1 + p[t[i.x]];
  63.  
  64. sol = max(sol1,sol);
  65. }
  66.  
  67. printf("%d\n",sol);
  68.  
  69. }
  70.  
  71. return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement