Submission #692706

#TimeUsernameProblemLanguageResultExecution timeMemory
692706zeroesandonesLightning Rod (NOI18_lightningrod)C++17
76 / 100
1399 ms262144 KiB
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef long double ld; typedef vector<ll> vi; typedef pair<ll, ll> pi; #define FOR(i, j, k) for (ll i = j; i < (ll) k; ++i) #define FORD(i, j, k) for (ll i = j; i >= (ll) k; --i) #define nl "\n" #define sp " " #define all(x) (x).begin(), (x).end() #define sc second #define fr first #define pb emplace_back void solve() { ll n; cin >> n; ll x[n], y[n]; FOR(i, 0, n) { cin >> x[i] >> y[i]; } stack<pi> s; for(int i = 0; i < n; ++i) { bool add = true; while(!s.empty()) { auto [nx, ny] = s.top(); if(abs(nx - x[i]) <= ny - y[i]) { add = false; break; } else if(abs(nx - x[i]) <= y[i] - ny) { s.pop(); } else { break; } } if(add) s.push({x[i], y[i]}); } cout << s.size() << nl; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll t = 1; // cin >> t; 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...