Submission #646541

#TimeUsernameProblemLanguageResultExecution timeMemory
646541kith14Lightning Rod (NOI18_lightningrod)C++17
100 / 100
1781 ms229556 KiB
#include <bits/stdc++.h> using namespace std; #define ll int #define db double #define pairll pair<ll,ll> #define lpairll pair<ll,pairll> #define repp(i,a,b) for (ll i = a; i <= b; i++) #define repz(i,a,b) for (ll i = a; i < b; i++) #define repm(i,a,b) for (ll i = a; i >= b; i--) #define fr first #define sc second #define x first #define y second #define mp make_pair #define pb push_back const ll N = 5e5+5, MOD = 1e9+7; ll tc = 1, n, m, xr[N], yr[N]; string s, s1, s2, ye = "YA", no = "TIDAK"; void input(){ cin >> n; } //check if a can consume b bool eat(pairll a, pairll b){ if (a == b) return 1; if (a.sc > b.sc){ ll df = a.sc-b.sc; if (a.fr-df <= b.fr && b.fr <= a.fr+df) return 1; } return 0; } void solve(){ vector<pairll> v; //note that xr is increasing repp(i,1,n){ ll xr, yr; cin >> xr >> yr; //while current point can consume other points while(v.size() && eat(mp(xr,yr),v.back())){ v.pop_back(); } //if empty or the last point cannot consume current point if (v.empty() || !eat(v.back(),mp(xr,yr))) v.pb(mp(xr,yr)); } cout << v.size() << endl; //for (auto i : v) cout << i.fr << " " << i.sc << endl; } int main(){ ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); //cin >> tc; while(tc--){ input(); 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...