This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define ll long long
#define pii pair<ll,ll>
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second
using namespace std;
bool cmp(pair<ll,pii> a,pair<ll,pii> b){
if(a.f==b.f)return a.s.s-a.s.f<b.s.s-b.s.f;
return a.f<b.f;
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
ll n;cin>>n;
vector<pair<ll,pii>>q;
for(int i=0;i<n;i++){
int si,ti;cin>>si>>ti;
q.pb({si+ti,{si,ti}});
}sort(q.begin(),q.end(),cmp);
stack<ll>st;
for(int i=0;i<n;i++){
while(!st.empty()&&st.top()<=q[i].s.s-q[i].s.f)st.pop();
st.push(q[i].s.s-q[i].s.f);
}cout<<st.size();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |