답안 #147003

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
147003 2019-08-27T03:54:52 Z jun6873 Lightning Rod (NOI18_lightningrod) C++11
100 / 100
679 ms 190460 KB
#include <bits/stdc++.h>
using namespace std;

using lint = long long;
using pint = pair<lint, lint>;
#define x first
#define y second

const int maxn = 10000004;
int n, k, b[maxn];
pint a[maxn];

static char buf[1 << 19]; // size : any number geq than 1024
static int idx = 0;
static int bytes = 0;
static inline int _read() {
    if (!bytes || idx == bytes) {
        bytes = (int)fread(buf, sizeof(buf[0]), sizeof(buf), stdin);
        idx = 0;
    }
    return buf[idx++];
}
static inline int _readInt() {
    int x = 0, s = 1;
    int c = _read();
    while (c <= 32) c = _read();
    if (c == '-') s = -1, c = _read();
    while (c > 32) x = 10 * x + (c - '0'), c = _read();
    if (s < 0) x = -x;
    return x;
}

int main() {
    n = _readInt();
    for (int i=0; i<n; i++) {
        int x, y;
        x = _readInt(); y = _readInt();
        a[i] = pint(x+y, y-x);
    }

    for (int i=0; i<n; i++) {
        while (k and a[b[k-1]].y <= a[i].y) k--;
        if (!k or a[b[k-1]].x < a[i].x) b[k++] = i;
    }

    cout << k << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 514 ms 190460 KB Output is correct
2 Correct 504 ms 190072 KB Output is correct
3 Correct 490 ms 185080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 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 252 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 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 252 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
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 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 252 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 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 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 252 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 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 17 ms 3704 KB Output is correct
15 Correct 16 ms 3832 KB Output is correct
16 Correct 16 ms 4088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 506 ms 181112 KB Output is correct
2 Correct 516 ms 181012 KB Output is correct
3 Correct 526 ms 176604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 514 ms 190460 KB Output is correct
2 Correct 504 ms 190072 KB Output is correct
3 Correct 490 ms 185080 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 376 KB Output is correct
9 Correct 2 ms 252 KB Output is correct
10 Correct 2 ms 376 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 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 17 ms 3704 KB Output is correct
18 Correct 16 ms 3832 KB Output is correct
19 Correct 16 ms 4088 KB Output is correct
20 Correct 506 ms 181112 KB Output is correct
21 Correct 516 ms 181012 KB Output is correct
22 Correct 526 ms 176604 KB Output is correct
23 Correct 679 ms 142652 KB Output is correct
24 Correct 639 ms 147548 KB Output is correct
25 Correct 641 ms 149964 KB Output is correct