Submission #1315563

#TimeUsernameProblemLanguageResultExecution timeMemory
1315563chithanhnguyenLightning Rod (NOI18_lightningrod)C++20
100 / 100
270 ms131824 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; 

inline void input(int & x) {
  x = 0;
  char ch = getchar_unlocked();
  while (ch < '0' || ch > '9') ch = getchar_unlocked();
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch & 15);
    ch = getchar_unlocked();
  }
}

inline void solve() {
    cin >> n;
    vector<pii> st;
    for (int i = 1; i <= n; ++i) {
        int x, y;
        input(x);
        input(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...