# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
95195 | win11905 | Lightning Rod (NOI18_lightningrod) | C++11 | 2069 ms | 138944 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.
/**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author win11905
*/
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define iii tuple<int, int, int>
#define long long long
#define pii pair<int, int>
#define x first
#define y second
using namespace std;
const long MOD = 1e9+7, LINF = 1e18 + 1e16;
const int INF = 1e9+1;
const double EPS = 1e-10;
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
int n;
stack<pii> stk;
bool check_cover(pii a, pii b) {
return abs(a.x - b.x) <= a.y - b.y;
}
int32_t main() {
scanf("%d", &n);
vector<pii> vec;
for(int i = 0, a, b; i < n; ++i) {
scanf("%d %d", &a, &b);
vec.emplace_back(a, b);
}
for(auto v : vec) {
if(stk.empty()) {
stk.emplace(v);
continue;
}
if(check_cover(stk.top(), v)) continue;
while(!stk.empty() && check_cover(v, stk.top())) stk.pop();
stk.emplace(v);
}
printf("%d\n", (int)stk.size());
}
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... |