제출 #1196802

#제출 시각아이디문제언어결과실행 시간메모리
1196802loomLightning Rod (NOI18_lightningrod)C++20
100 / 100
528 ms234324 KiB
#include <bits/stdc++.h> using namespace std; #define int long long 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; } signed main(){ int n = readInt(); vector<pair<int,int>> a(n); for(int i = 0; i < n; i++) { a[i].first = readInt(); a[i].second = readInt(); if(i > 0 and a[i].first == a[i-1].first) cout<<"haha"; } int ans = n; int mx = -1; vector<int> tf(n, 0); for(int i=0; i<n; i++){ auto [x, y] = a[i]; if(x+y <= mx) ans--, tf[i] = 1; else mx = x+y; } int mn = 1e18; for(int i=n-1; i>=0; i--){ if(tf[i]) continue; auto [x, y] = a[i]; if(x-y >= mn) ans--; else mn = x-y; } cout<<ans; 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...