Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- #include<map>
- #include<algorithm>
- using namespace std;
- pair<long long,long long>A[100013];
- map <int,long long> QW;
- long long F[100013];
- long long tr[1000013];
- void build(long long v,long long l,long long r)
- {
- if(l>r)
- {
- return;
- }
- if(l==r)
- {
- tr[v]=l;
- }
- long long m=(l+r)/2;
- build(2*v,l,m);
- build(2*v+1,m+1,r);
- if(A[tr[2*v]].first+A[tr[2*v]].second>A[tr[2*v+1]].first+A[tr[2*v+1]].second)
- {
- tr[v] = tr[2*v];
- }
- else
- {
- tr[v]=tr[2*v+1];
- }
- }
- long long max1(long long v,long long l,long long r,long long l1,long long r1)
- {
- if(l>r)
- {
- return -1000000000;
- }
- if(l1>r)
- {
- return -1000000000;
- }
- if(r1<l)
- {
- return -1000000000;
- }
- if((l1==l)&&(r1==r))
- {
- return tr[v];
- }
- long long x,y;
- long long m=(l+r)/2;
- x=max1(2*v,l,m,l1,max(m,r1));
- y=max1(2*v+1,m+1,r,max(m+1,l1),r1);
- if(A[x].first+A[x].second>A[y].first+A[y].second)
- {
- return x;
- }
- else
- {
- return y;
- }
- }
- int main()
- {
- int a;
- cin>>a;
- long long k1,k2;
- for(int i=1;i<=a;i++)
- {
- cin>>k1>>k2;
- A[i].first=k1;
- A[i].second=k2;
- QW[i]=k1;
- }
- sort(A+1,A+a+1);
- for(int i=
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement