# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
95562 | oolimry | Lightning Rod (NOI18_lightningrod) | C++14 | 1350 ms | 144868 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>
using namespace std;
inline 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 X[10000000], Y[10000000];
bool in(int a, int b){
/// if b is under a, return true
int x1 = X[a];
int x2 = X[b];
int y1 = Y[a];
int y2 = Y[b];
return abs(x1 - x2) <= y1 - y2;
}
int main(){
//freopen("i.txt.txt","r",stdin);
int n = readInt();
for(int i = 0; i < n; i++) {
X[i] = readInt();
Y[i] = readInt();
// write code here
}
// write code here
//for(int i = 0;i < n;i++){
//printf("%d %d\n",X[i],Y[i]);
//}
stack<int> s;
if(in(2,3)){
//printf("yes");
}
for(int i = 0;i < n;i++){
if(s.empty()){
s.push(i);
continue;
}
else if(in(s.top(),i)){
continue;
}
else if(in(i,s.top())){
while(!s.empty() && in(i,s.top())){
s.pop();
}
s.push(i);
}
else{
s.push(i);
}
}
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... |