Submission #95196

# Submission time Handle Problem Language Result Execution time Memory
95196 2019-01-28T13:04:44 Z win11905 Lightning Rod (NOI18_lightningrod) C++11
100 / 100
1467 ms 190300 KB
/**
 * 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;
}

void fastscan(int &x)
    {
        bool neg=false;
        register int c;
        x =0;
        c=getchar();
        if(c=='-')
        {
            neg = true;
            c=getchar();
        }
        for(;(c>47 && c<58);c=getchar())
            x = (x<<1) + (x<<3) +c -48;
        if(neg)
            x *=-1;
    }

int32_t main() {
    fastscan(n);
    vector<pii> vec;
    vec.reserve(n+5);
    for(int i = 0, a, b; i < n; ++i) {
        fastscan(a);
        fastscan(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());
}
# Verdict Execution time Memory Grader output
1 Correct 1066 ms 155852 KB Output is correct
2 Correct 1129 ms 190300 KB Output is correct
3 Correct 1086 ms 185132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 32 ms 2424 KB Output is correct
15 Correct 31 ms 2556 KB Output is correct
16 Correct 28 ms 3064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 961 ms 129532 KB Output is correct
2 Correct 945 ms 158860 KB Output is correct
3 Correct 927 ms 154736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1066 ms 155852 KB Output is correct
2 Correct 1129 ms 190300 KB Output is correct
3 Correct 1086 ms 185132 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 32 ms 2424 KB Output is correct
18 Correct 31 ms 2556 KB Output is correct
19 Correct 28 ms 3064 KB Output is correct
20 Correct 961 ms 129532 KB Output is correct
21 Correct 945 ms 158860 KB Output is correct
22 Correct 927 ms 154736 KB Output is correct
23 Correct 1467 ms 108708 KB Output is correct
24 Correct 1328 ms 117976 KB Output is correct
25 Correct 1225 ms 113500 KB Output is correct