# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
425457 | errorgorn | Lightning Rod (NOI18_lightningrod) | C++17 | 794 ms | 192252 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include <cstdio>
#include <stack>
using namespace std;
inline void read(int& x) {
x = 0;
char ch = getchar_unlocked();
while (ch&16){ //this will break when ‘\n’ or ‘ ‘ is encountered
x = (x << 3) + (x << 1) + (ch&15);
ch = getchar_unlocked();
}
}
int x,y;
typedef pair<int,int> ii;
stack<ii> s;
int main(){
int N;
read(N);
read(x),read(y);
s.push(ii(x,y));
for(int i = 1; i < N; i++) {
read(x),read(y);
if (x-s.top().first>s.top().second-y){
while (!s.empty() && x-s.top().first<=y-s.top().second){
s.pop();
}
s.push(ii (x,y));
}
}
printf("%d",s.size());
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |