제출 #1118695

#제출 시각아이디문제언어결과실행 시간메모리
1118695HuyATAdvertisement 2 (JOI23_ho_t2)C++14
100 / 100
132 ms4748 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...