Submission #425589

#TimeUsernameProblemLanguageResultExecution timeMemory
425589EleCursityLightning Rod (NOI18_lightningrod)C++17
100 / 100
936 ms191852 KiB
#include <bits/stdc++.h> using namespace std; int readInt(){ int x = 0; char ch = getchar(); while (ch < '0' || ch > '9') ch = getchar(); while (ch >= '0' && ch <= '9'){ x = (x << 3) + (x << 1) + ch - '0'; ch = getchar(); } return x; } int main(){ int n = readInt(); stack<pair<int,int> > stk; for(int i=1;i<=n;i++){ int x = readInt(); int y = readInt(); if(stk.empty()){ stk.push({x,y}); } else{ while(!stk.empty()){ int xx = stk.top().first; int yy = stk.top().second; if(yy>y){ int dx = x-xx; int dy = yy-y; if(dy<dx){ stk.push({x,y}); } break; } int dx = x-xx; int dy = y-yy; if(dy>=dx){ stk.pop(); }else{ stk.push({x,y}); break; } } if(stk.empty()){ stk.push({x,y}); } } } cout<<stk.size()<<endl; 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...