Submission #744004

#TimeUsernameProblemLanguageResultExecution timeMemory
744004vjudge1Lightning Rod (NOI18_lightningrod)C++17
100 / 100
1691 ms156524 KiB
#include<bits/stdc++.h> using namespace std; struct point { int x,y; }; int n; vector<point> vec; stack<point> st; int cnt = 0; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for(int i=0;i<n;++i) { int a,b; cin >> a >> b; vec.push_back({a,b}); } for(int i=0;i<n;++i) { while(!st.empty() && vec[i].y-st.top().y >= vec[i].x-st.top().x) st.pop(); if(st.empty() || !(st.top().y-vec[i].y >= vec[i].x-st.top().x)) { // cout << "add " << vec[i].x << " " << vec[i].y << '\n'; st.push({vec[i].x,vec[i].y}); } } cout << st.size(); 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...