Submission #1315552

#TimeUsernameProblemLanguageResultExecution timeMemory
1315552chithanhnguyenLightning Rod (NOI18_lightningrod)C++20
80 / 100
1095 ms131880 KiB
/*
Author: Nguyen Chi Thanh - High School for the Gifted - VNU.HCM (i2528)
*/
#include <bits/stdc++.h>
using namespace std;

// #define int long long
#define ull unsigned long long
#define ld long double
#define pii pair<int, int>
#define fi first
#define se second
#define __builtin_popcount __builtin_popcountll
#define all(x) (x).begin(), (x).end()
#define BIT(x, i) (((x) >> (i)) & 1)
#define MASK(x) ((1ll << (x)))

#define debug(a, l, r) for (int _i = (l); _i <= (r); ++_i) cout << (a)[_i] << ' '; cout << '\n';

int n; 

void solve() {
    cin >> n;
    vector<pii> st;
    for (int i = 1; i <= n; ++i) {
        int x, y; cin >> x >> y;
        pii p = {x + y, x - y};

        bool need = 1;
        while (!st.empty()) {
            int _x = st.back().fi, _y = st.back().se;

            if (p.fi <= _x && p.se >= _y) {
                need = 0;
                break;
            }

            if (_x <= p.fi && _y >= p.se) st.pop_back();
            else break;
        }

        if (need) st.push_back(p);
    }

    cout << (int)st.size();
}


signed main() {
    #ifdef NCTHANH
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);

    solve();

    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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...