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>
using namespace std;
#define int long long
#define pii pair<int, int>
void transform(pii& a){
pii b= a;
a.first = b.first+b.second;
a.second = b.second-b.first;
}
signed main(){
int n;
cin>>n;
vector<pii> a(n);
for(int i = 0; i<n; i++){
cin>>a[i].first>>a[i].second;
transform(a[i]);
}
sort(a.begin(), a.end());
vector<pii> st;
for(int i = 0; i<n; i++){
while(st.size()>0 && st.back().second<=a[i].second){
st.pop_back();
}
st.push_back(a[i]);
}
cout<<st.size()<<endl;
}
# | 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... |