Submission #866536

#TimeUsernameProblemLanguageResultExecution timeMemory
866536goodspeed0208Advertisement 2 (JOI23_ho_t2)C++14
100 / 100
135 ms13392 KiB
#include<iostream> #include<vector> #include<algorithm> #include<utility> #define int long long using namespace std; bool cmp(pair<int, int> a, pair<int, int> b) { if (a.first == b.first) return a.second > b.second; return a.first < b.first; } signed main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<pair<int, int> >v(n); int a, b; for (int i = 0 ; i < n ; i++) { cin >> a >> b; v[i] = {a-b, a+b}; //cout << a-b << " " << a+b << "\n"; } sort(v.begin(), v.end(), cmp); int ans = 1, right = v[0].second; for (int i = 1 ; i < n ; i++) { if (v[i].second <= right) continue; ans++; right = v[i].second; } cout << ans << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...