Submission #197516

#TimeUsernameProblemLanguageResultExecution timeMemory
197516handlenameLightning Rod (NOI18_lightningrod)C++17
100 / 100
486 ms166172 KiB
#include <bits/stdc++.h> using namespace std; 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 x,y; stack<pair<int,int> > chosen; int main(){ int n=readInt(); for (int i = 0; i < n; i++) { x = readInt(); y = readInt(); if (!chosen.empty() && x-chosen.top().first<=chosen.top().second-y) continue; while (!chosen.empty() && x-chosen.top().first<=y-chosen.top().second){ chosen.pop(); } chosen.push(make_pair(x,y)); } cout<<chosen.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...