Submission #1249695

#TimeUsernameProblemLanguageResultExecution timeMemory
1249695norman165Advertisement 2 (JOI23_ho_t2)C++20
59 / 100
2090 ms3232 KiB
#include <bits/stdc++.h>

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define int long long
#define yes() cout << "YES\n"
#define no() cout << "NO\n"

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

const int inf = 1e18;
const int mod = 1e9 + 7;
const int maxn = 1e7 + 5e6;
const int mod1 = 998244353;
const int mod2 = 1e18 + 1;
const int mod3 = 1e9 + 9;
const int mod4 = 333333333;
const int mod5 = 200000;
const int mod6 = 10007;
const int k = 300;
const int w = 1e5;
const ld EPS = 1e-8;

int LOG = 30;

void solve() {
    int n;
    cin >> n;

    vector<pair<int, int>> a(n);
    for (auto& i : a) cin >> i.first >> i.second;

    sort(all(a), [&](pair<int, int> a, pair<int, int> b) {
        return a.second < b.second || (a.second == b.second && a.first < b.first);
    });

    int ans = n;
    vector<int> cnt(n);
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (a[i].first >= a[j].first) {
                if (a[i].first + a[i].second <= a[j].first + a[j].second) cnt[i] = 1;
            } else {
                if (a[i].second - a[i].first <= a[j].second - a[j].first) cnt[i] = 1;
            }
            // if (abs(a[i].first - a[j].first) <= a[j].second - a[i].second) cnt[i] = 1;
        }
    }

    cout << ans - accumulate(all(cnt), 0ll) << "\n";
}

signed main() {
    // cout.precision(16);

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    // cin >> t;

    while (t--) {
        solve();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...