제출 #1134728

#제출 시각아이디문제언어결과실행 시간메모리
1134728AvianshLightning Rod (NOI18_lightningrod)C++17
0 / 100
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; array<int,2>arr[n]; for(int i = 0;i<n;i++){ cin >> arr[i][0]; cin >> arr[i][1]; } 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...