Submission #1309531

#TimeUsernameProblemLanguageResultExecution timeMemory
1309531tntLightning Rod (NOI18_lightningrod)C++20
100 / 100
333 ms88112 KiB
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast,fast-math,O3")

#define pb push_back                    
#define ll long long  
#define f first
#define s second
//#define sz(v) int(v.size())
#define all(v) v.begin(),v.end()

int mod =  1e9 + 7;
const int N = 1e7 + 2,k = 317 + 1;
const int inf = 2e9;
int pr = -inf,sf = inf;
bool d[N];
inline int func(){
    int x = 0;
    int f = 1;
    char ch = getchar_unlocked();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar_unlocked();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + (ch - '0');
        ch = getchar_unlocked();
    }
    return x * f;
}
void solve(){
    int n,ans = 0;
    n = func();
    int x[n + 1],y[n + 1];
    int g;
    for(int i = 1; i <= n; i++){
        x[i] = func(),y[i] = func();
        g = x[i] + y[i];
        d[i] |= (pr >= g);
        pr = max(pr,g);
    }
    for(int i = n; i >= 1; i--){
        g = x[i] - y[i];
        d[i] |= (sf <= g);
        sf = min(sf,g);
        ans += (d[i] == 0);
    }
    cout << ans;
}
signed main(){
    //freopen("time.in", "r", stdin);
    //freopen("time.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t = 1;
    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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...