제출 #1323001

#제출 시각아이디문제언어결과실행 시간메모리
1323001aaaaaaaaAdvertisement 2 (JOI23_ho_t2)C++20
100 / 100
151 ms12088 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()
const int inf = 1e18;
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vector<pair<int, int>> v;
    for(int i = 1, x, e; i <= n; ++i){
        cin >> x >> e;
        v.push_back({x - e, x + e});
    }
    sort(all(v), [&](pair<int, int> x, pair<int, int> y){
        if(x.first == y.first) return x.second > y.second;
        return x.first < y.first;
    });
    int mx = v[0].second, ans = 1;
    vector<int> dp(n, 0);
    dp[0] = 1;
    for(int j = 1; j < n; ++j){
        if(mx >= v[j].second) dp[j] = 0;
        else dp[j] = 1;
        mx = max(mx, v[j].second);
        ans += dp[j];
    }
    cout << ans << "\n";
    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...