Submission #1327831

#TimeUsernameProblemLanguageResultExecution timeMemory
1327831BolatuluAdvertisement 2 (JOI23_ho_t2)C++20
100 / 100
116 ms12480 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define all(x) (x).begin(), (x).end()
#define md ((tl + tr) >> 1)
#define TL v + v, tl, md
#define TR v + v + 1, md + 1, tr
#define F first
#define S second
#define pii pair<int, int>
#define int ll

const int maxn = 5e5 + 7;
const ll inf = 1e18 + 7;

int n;
pii p[maxn];

void solve() {
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> p[i].F >> p[i].S;
    sort(p + 1, p + n + 1);

    vector<int> v;
    for (int i = 1; i <= n; i++) {
        while (!v.empty() && p[i].S - p[v.back()].S >= p[i].F - p[v.back()].F)
            v.pop_back();
        if (v.empty() || p[v.back()].S - p[i].S < p[i].F - p[v.back()].F)
            v.push_back(i);
    }
    cout << v.size();
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int test = 1;
    // cin >> test;
    while (test--) {
        solve();
        // cout << '\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...