# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
970508 | NoMercy | Lightning Rod (NOI18_lightningrod) | C++17 | 2065 ms | 1948 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;
int TIME = clock();
#define file \
freopen("in.txt" , "r" , stdin); \
freopen("out.txt" , "w" , stdout);
void test_case () {
int n;
cin >> n;
stack <array <int , 2>> st;
for (int i = 0;i < n;i ++) {
int x , y;
cin >> x >> y;
array<int , 2> tmp = {x , y};
if (st.size() == 0) {
st.push({x , y});
continue;
}
if (abs(x - st.top()[0]) <= st.top()[0] - y) {
continue;
}
while ((int)st.size() > 0 && abs(st.top()[0] - x) <= y - st.top()[1]) {
st.pop();
}
st.push({x , y});
}
cout << st.size() << "\n";
}
int32_t main () {
//// file
int t = 1;
// cin >> t;
while (t --) {
test_case();
}
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... |