# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
219586 | GioChkhaidze | Lightning Rod (NOI18_lightningrod) | C++14 | 2080 ms | 171132 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;
const int N=1e7+7;
bool f[N];
int n,x[N],y[N];
stack < int > st;
main () {
scanf("%d",&n);
for (int i=1; i<=n; i++) {
scanf("%d%d",&x[i],&y[i]);
}
int ans=n;
for (int i=1; i<=n; i++) {
if (st.size()) {
while (st.size() && x[st.top()]-y[st.top()]>=x[i]-y[i]) {
f[st.top()]=1;
--ans;
st.pop();
}
}
st.push(i);
}
while (st.size()) st.pop();
for (int i=n; i>=1; i--) {
if (f[i]) continue;
if (st.size()) {
while (st.size() && x[st.top()]+y[st.top()]<=x[i]+y[i]) {
f[st.top()]=1;
--ans;
st.pop();
}
}
st.push(i);
}
printf("%d\n",ans);
}
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... |