Submission #1300590

#TimeUsernameProblemLanguageResultExecution timeMemory
1300590danglayloi1Lightning Rod (NOI18_lightningrod)C++20
0 / 100
1098 ms79712 KiB
#include <bits/stdc++.h> #define ii pair<int, int> #define fi first #define se second #define inf 0x3f3f3f3f3f3f3f3f using namespace std; using ll = long long; const ll mod=1e9+7; const int nx=1e7+5; int n, ans=0, cur=-1; stack<ii> st; inline int readInt() { int x = 0; char ch = getchar_unlocked(); 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; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n; for(int i = 1; i <= n; i++) { int x=readInt(), y=readInt(); bool ok=1; while(st.size()) { ii p=st.top(); if(x-p.fi<=p.se-y) { ok=0; break; } if(x-p.fi<=y-p.se) st.pop(); else break; } if(ok) st.push({x, y}); } cout<<st.size(); }
#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...