제출 #879562

#제출 시각아이디문제언어결과실행 시간메모리
879562huutuanAdvertisement 2 (JOI23_ho_t2)C++14
100 / 100
121 ms18268 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define isz(x) ((int)x.size()) #define sumof(x) accumulate(all(x), 0ll) void solve(){ int n; cin >> n; vector<pair<int, int>> v; for (int i=1; i<=n; ++i){ int x, e; cin >> x >> e; v.emplace_back(x-e, e+x); } sort(all(v), [&](pair<int, int> x, pair<int, int> y){ return x.first!=y.first?x.first<y.first:x.second>y.second; }); int last=-1e18, ans=0; for (auto &i:v){ if (last<i.second){ last=max(last, i.second); ++ans; } } cout << ans; } int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int ntests=1; // cin >> ntests; for (int i=1; i<=ntests; ++i) 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...