fork download
  1. /*
  2.   Archit Jain
  3.   handles: archit_jain08,DTU
  4.   */
  5. #include<bits/stdc++.h>
  6.  
  7. #ifdef ONLINE_JUDGE
  8. #define gc getchar_unlocked
  9. #else
  10. #define gc getchar
  11. #endif
  12.  
  13. using namespace std;
  14.  
  15. #define sd(x) scanf("%d",&x)
  16. #define sld(x) scanf("%ld",&x);
  17. #define slld(x) scanf("%lld",&x);
  18. #define sf(x) scanf("%f",&x);
  19. #define slf(x) scanf("%llf",&x);
  20. #define str(x) scanf("%s",&x);
  21. #define strs(x) scanf("%[^\n]s",&x)
  22. #define pd(x) printf("%d",x);
  23. #define pld(x) printf("%ld",x);
  24. #define plld(x) printf("%lld",x);
  25. #define pstr(x) printf("%s",x);
  26. #define pf(x,y) printf("%.yf",x)
  27. #define nL printf("\n")
  28. #define TAB printf(" ")
  29.  
  30. #define lld long long int
  31. #define ld long int
  32.  
  33. typedef vector<int> vd;
  34. typedef vector<vector<int> > v2d;
  35. typedef queue<int> q;
  36. typedef pair<int,int> p;
  37. typedef queue<p> qp;
  38.  
  39. #define REP(i,a,b,c) for(int i=a;i<=b;i+=c)
  40. #define REPR(i,a,b,c) for(int i=a;i>=b;i-=c)
  41. #define MEM(x,value) memset(x,value,sizeof(x))
  42. #define mp(a,b) make_pair(a,b)
  43. #define INF INT_MAX
  44. #define MAX 1048580
  45.  
  46. template<class T>
  47. void fs(T &x)
  48. {
  49. register T c = gc();
  50. x = 0;
  51. for(;(c<48 || c>57);c = gc());
  52. for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
  53. }
  54. template<class T> T mx(T a,T b){return (a>b)?a:b;}
  55. template<class T> T mn(T a,T b){return (a<b)?a:b;}
  56.  
  57. struct node
  58. {
  59. ld open;
  60. ld school;
  61. ld number;
  62. }a[300005];
  63.  
  64. bool compare(node a,node b)
  65. {
  66. return ((a.school>b.school&&a.open>=b.open)||(a.school>=b.school&&a.open>b.open))?true:false;
  67. }
  68.  
  69. int dp[300005];
  70.  
  71. int main()
  72. {
  73. ld t;
  74. sld(t);
  75. REP(i,0,t-1,1)
  76. {
  77. sld(a[i].open);
  78. sld(a[i].school);
  79. a[i].number =i+1;
  80. }
  81.  
  82. sort(a,a+t,compare);
  83.  
  84. REPR(i,t-1,0,1)
  85. {
  86. if(i==t-1)
  87. {
  88. dp[a[i].number]=0;
  89. }
  90. else
  91. {
  92. if((a[i].open>a[i+1].open&&a[i].school>=a[i+1].school)||(a[i].open>=a[i+1].open&&a[i].school>a[i+1].school))
  93. dp[a[i].number] = t-1-i;
  94. else
  95. dp[a[i].number] = dp[a[i+1].number];
  96. }
  97.  
  98. }
  99.  
  100. REP(i,1,t,1)
  101. {
  102. pd(dp[i]);
  103. nL;
  104. }
  105.  
  106. return 0;
  107. }
  108.  
Success #stdin #stdout 0s 7988KB
stdin
8
1798 1832
862 700
1075 1089
1568 1557
2575 1984
1033 950
1656 1649
1014 1473
stdout
6
0
3
4
7
1
5
1