답안 #894633

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
894633 2023-12-28T14:42:11 Z IWKR Lightning Rod (NOI18_lightningrod) C++17
100 / 100
441 ms 192648 KB
#include <bits/stdc++.h>
using namespace std;

inline int readInt() {
	int x = 0;
	char ch = getchar_unlocked();
	bool s = 1;
	while (ch < '0' || ch > '9') {
		if (ch == '-') {
			s = 0;
			ch = getchar_unlocked();
		}
	}
	while (ch >= '0' && ch <= '9') {
		x = (x << 3) + (x << 1) + ch - '0';
		ch = getchar_unlocked();
	}
	return s ? x : -x;
}

stack<pair<int, int>> s;

int main() {
    int n = readInt();
    for (int i = 0; i < n; i++) {
        int x = readInt();
		int y = readInt();
        bool add = 1;
        while (s.size()) {
            int tx = s.top().first;
            int ty = s.top().second;
            if (x - tx <= ty - y) {
                add = 0;
                break;
            }
            if (x - tx <= y - ty) {
                s.pop();
            } else {
                break;
            }
        }
        if (add) {
            s.push({x, y});
        }
    }
    cout << s.size();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 249 ms 192648 KB Output is correct
2 Correct 263 ms 191988 KB Output is correct
3 Correct 236 ms 186868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 440 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 440 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 440 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 436 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 440 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 436 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 9 ms 3932 KB Output is correct
15 Correct 8 ms 3668 KB Output is correct
16 Correct 7 ms 3672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 248 ms 147740 KB Output is correct
2 Correct 239 ms 147640 KB Output is correct
3 Correct 245 ms 144052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 249 ms 192648 KB Output is correct
2 Correct 263 ms 191988 KB Output is correct
3 Correct 236 ms 186868 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 440 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 436 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 9 ms 3932 KB Output is correct
18 Correct 8 ms 3668 KB Output is correct
19 Correct 7 ms 3672 KB Output is correct
20 Correct 248 ms 147740 KB Output is correct
21 Correct 239 ms 147640 KB Output is correct
22 Correct 245 ms 144052 KB Output is correct
23 Correct 441 ms 175872 KB Output is correct
24 Correct 372 ms 156788 KB Output is correct
25 Correct 328 ms 140640 KB Output is correct