Advertisement
Guest User

Untitled

a guest
May 29th, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. #include<cstdio>
  2. #include<cstdlib>
  3. #include<cmath>
  4. #include<cctype>
  5. #include<cstring>
  6.  
  7. #include<iostream>
  8. #include<string>
  9. #include<algorithm>
  10. #include<vector>
  11. #include<queue>
  12. #include<stack>
  13. #include<set>
  14. #include<map>
  15.  
  16. #define mset(a,v) memset(a,v,sizeof(a))
  17. #define read freopen("input.c","r",stdin)
  18. #define write freopen("output.txt","w",stdout)
  19. #define ll long long
  20. #define pii pair<int,int>
  21. #define Mx 100
  22. #define total 7
  23. #define Inf 2147364748
  24.  
  25. using namespace std;
  26.  
  27. struct abc
  28. {
  29. int value , mark ; // mark 0 for start point , 1 for end
  30. } Inp [ Mx + Mx ] ;
  31.  
  32. bool cmp ( abc A , abc B )
  33. {
  34. if ( A.value == B.value ) return A.mark < B.mark ; // start mark age thakbe
  35. return A.value < B.value ;
  36. }
  37.  
  38. int main()
  39. {
  40.  
  41.  
  42. int n , i , x , y , idx = 0;
  43. cin >> n ;
  44. for ( i = 0 ; i < n ; i++ )
  45. {
  46. cin >> x >> y ;
  47. Inp[idx].value = x ;
  48. Inp[idx++].mark = 0 ;
  49. Inp[idx].value = y ;
  50. Inp[idx++].mark = 1 ;
  51. }
  52. sort(Inp , Inp+idx , cmp );
  53.  
  54. /*
  55. cout<<endl<<endl;
  56.  
  57. for(i = 0 ; i<idx ; i++){
  58. cout<<Inp[i].value<<" "<<Inp[i].mark<<endl;
  59. }
  60.  
  61. */
  62.  
  63.  
  64. int Ans = -Inf ;
  65. int cur = 0 ; // eita count korbe koyta program ekhon run korche
  66. for ( i = 0 ; i < idx ; i++ )
  67. {
  68. if( Inp[i].mark == 0 ) // mane notun program start hoiche
  69. cur++;
  70. else cur-- ; // program off hoiche
  71. Ans = max(Ans , cur );
  72. }
  73. cout<<Ans<<endl;
  74.  
  75. return 0 ;
  76.  
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement