Advertisement
haufont

Untitled

Jul 21st, 2016
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. #include<map>
  4. #include<algorithm>
  5. using namespace std;
  6. pair<long long,long long>A[100013];
  7. map <int,long long> QW;
  8. long long F[100013];
  9. long long tr[1000013];
  10. void build(long long v,long long l,long long r)
  11. {
  12. if(l>r)
  13. {
  14. return;
  15. }
  16. if(l==r)
  17. {
  18. tr[v]=l;
  19. }
  20. long long m=(l+r)/2;
  21. build(2*v,l,m);
  22. build(2*v+1,m+1,r);
  23. if(A[tr[2*v]].first+A[tr[2*v]].second>A[tr[2*v+1]].first+A[tr[2*v+1]].second)
  24. {
  25. tr[v] = tr[2*v];
  26. }
  27. else
  28. {
  29. tr[v]=tr[2*v+1];
  30. }
  31. }
  32. long long max1(long long v,long long l,long long r,long long l1,long long r1)
  33. {
  34. if(l>r)
  35. {
  36. return -1000000000;
  37. }
  38. if(l1>r)
  39. {
  40. return -1000000000;
  41. }
  42. if(r1<l)
  43. {
  44. return -1000000000;
  45. }
  46. if((l1==l)&&(r1==r))
  47. {
  48. return tr[v];
  49. }
  50. long long x,y;
  51. long long m=(l+r)/2;
  52. x=max1(2*v,l,m,l1,max(m,r1));
  53. y=max1(2*v+1,m+1,r,max(m+1,l1),r1);
  54. if(A[x].first+A[x].second>A[y].first+A[y].second)
  55. {
  56. return x;
  57. }
  58. else
  59. {
  60. return y;
  61. }
  62. }
  63. int main()
  64. {
  65. int a;
  66. cin>>a;
  67. long long k1,k2;
  68. for(int i=1;i<=a;i++)
  69. {
  70. cin>>k1>>k2;
  71. A[i].first=k1;
  72. A[i].second=k2;
  73. QW[i]=k1;
  74. }
  75. sort(A+1,A+a+1);
  76. for(int i=
  77.  
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement