Submission #1134730

#TimeUsernameProblemLanguageResultExecution timeMemory
1134730AvianshLightning Rod (NOI18_lightningrod)C++17
0 / 100
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; inline int readInt() { int x = 0; char ch = getchar(); while (ch < '0' || ch > '9') ch = getchar_unlocked(); while (ch >= '0' && ch <= '9'){ x = (x << 3) + (x << 1) + ch - '0'; ch = getchar_unlocked(); } return x; } int X[10000000], Y[10000000]; int main(){ int n = readInt(); array<int,2>arr[n]; for(int i = 0; i < n; i++) { X[i] = readInt(); Y[i] = readInt(); arr[i][0]=X[i]; arr[i][1]=Y[i]; } int p[n]; fill(p,p+n,-1); int prev = 0; for(int i = 1;i<n;++i){ if(arr[i][0]-arr[prev][0]<=arr[prev][1]-arr[i][1]){ p[i]=prev; } else{ prev=i; } } prev=n-1; for(int i = n-2;i>=0;--i){ if(arr[prev][0]-arr[i][0]<=arr[prev][1]-arr[i][1]){ p[i]=prev; } else{ prev=i; } } int ans = 0; for(int i = 0;i<n;++i){ if(p[i]==-1){ ans++; } } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...