이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define newl '\n'
const int N = 5e5 + 10;
const int V = 1e7 + 10;
const long long INF = 1e18;
const long long M = 1e9 + 7;
int n,id[N + 1];
std::pair<int,int> p[N + 1];
void readData(){
std::cin >> n;
for(int i = 1;i <= n;++i){
int x,e;
std::cin >> x >> e;
p[i] = {x - e,x + e};
}
auto cmp = [&](std::pair<int,int> &lhs,std::pair<int,int> &rhs){
return (lhs.first < rhs.first || (lhs.first == rhs.first && lhs.second > rhs.second));
};
std::sort(p + 1,p + n + 1,cmp);
}
void solve(){
int ans = 0,mx = 0;
for(int i = 1;i <= n;++i){
if(mx < p[i].second){
++ans;
}
mx = std::max(mx,p[i].second);
}
std::cout << ans;
}
int main(){
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);std::cout.tie(nullptr);
readData();
solve();
return 0;
}
# | 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... |