답안 #921517

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
921517 2024-02-04T04:42:02 Z Bzslayed Lightning Rod (NOI18_lightningrod) C++17
100 / 100
343 ms 193136 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define coutpair(p) cout << p.first << " " << p.second << "\n"

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;

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<pii> s;
int main(){
    ios_base::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);

    int n = readInt();
    for (int i=0; i<n; i++){
        int x = readInt();
        int y = readInt();
        bool add = true;
        while (s.size()) {
            int fx = s.top().first;
            int fy = s.top().second;
            if (x-fx <= fy-y) {
                add = false;
                break;
            }
            if (x-fx <= y-fy) {
                s.pop();
            } 
            else break;
        }
        if (add) s.push({x, y});
    }
    cout << s.size();

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 264 ms 192524 KB Output is correct
2 Correct 257 ms 193136 KB Output is correct
3 Correct 260 ms 186892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 0 ms 348 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 1 ms 600 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 0 ms 348 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 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 0 ms 348 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 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 0 ms 348 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 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 8 ms 3884 KB Output is correct
15 Correct 7 ms 3676 KB Output is correct
16 Correct 9 ms 3676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 282 ms 147820 KB Output is correct
2 Correct 314 ms 147604 KB Output is correct
3 Correct 273 ms 144092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 264 ms 192524 KB Output is correct
2 Correct 257 ms 193136 KB Output is correct
3 Correct 260 ms 186892 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 460 KB Output is correct
7 Correct 0 ms 348 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 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 8 ms 3884 KB Output is correct
18 Correct 7 ms 3676 KB Output is correct
19 Correct 9 ms 3676 KB Output is correct
20 Correct 282 ms 147820 KB Output is correct
21 Correct 314 ms 147604 KB Output is correct
22 Correct 273 ms 144092 KB Output is correct
23 Correct 343 ms 175896 KB Output is correct
24 Correct 299 ms 157128 KB Output is correct
25 Correct 299 ms 140616 KB Output is correct