Submission #1316689

#TimeUsernameProblemLanguageResultExecution timeMemory
1316689minggaAdvertisement 2 (JOI23_ho_t2)C++20
100 / 100
113 ms8256 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

struct Resident {
    ll l, r;
    bool operator<(const Resident& other) const {
        if (l != other.l) return l < other.l;
        return r > other.r;
    }
};

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    vector<Resident> a(n);
    for(int i=0; i<n; i++) {
        ll x, e; cin >> x >> e;
        a[i].l = x - e; a[i].r = x + e;
    }
    sort(a.begin(), a.end());
    int ans = 0;
    ll max_r = -2e18;
    for(int i=0; i<n; i++) {
        if (a[i].r > max_r) {
            ans++;
            max_r = a[i].r;
        }
    }
    cout << ans << endl;
    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...