Submission #1309509

#TimeUsernameProblemLanguageResultExecution timeMemory
1309509thecrazycandyLightning Rod (NOI18_lightningrod)C++20
66 / 100
1090 ms156500 KiB
#include <bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
using namespace std;
#define ll int
#define sped_up ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rall(v) (v).rbegin(), (v).rend()
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define S second
#define F first
const ll INF = (ll)1e9 + 1, INFL = (ll)1e18 + 1;
const ll mod = (ll)1e9 + 7, MAXN = (ll)1e7 + 7;
ll p[MAXN], s[MAXN];
int main() {
    sped_up;
    ll n;
    cin >> n;
    ll cnt = 0;
    vector <pair <ll, ll>> v;
    v.pb({0, 0});
    p[0] = -INF;
    s[n + 1] = INF;
    for (int i = 1; i <= n; i++) {
        ll x, y;
        cin >> x >> y;
        v.pb({x, y});
    }
    for (int i = 1; i <= n; i++) {
        ll x = v[i].F, y = v[i].S;
        p[i] = max(p[i - 1], x + y);
    }
    for (int i = n; i >= 1; i--) {
        ll x = v[i].F, y = v[i].S;
        s[i] = min(s[i + 1], x - y);
    }
    for (int i = 1; i <= n; i++) {
        ll x = v[i].F, y = v[i].S;
        if (s[i + 1] > x - y && x + y > p[i - 1]) cnt++;
    }
    cout << cnt;
}
#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...