Submission #740495

# Submission time Handle Problem Language Result Execution time Memory
740495 2023-05-12T15:20:31 Z mzv Lightning Rod (NOI18_lightningrod) C++17
100 / 100
1770 ms 232816 KB
#include <bits/stdc++.h>

#define ccd ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'

using namespace std;

/* ------------------------ hi lol ------------------------ */

// author : mzv

ll n,x,y;
stack<pair<ll,ll>> st;
bool useless;

int main() {
	ccd
	cin >> n;
	while (n--) {
		cin >> x >> y;
		useless=0;
		while (st.size()) {
			ll x2=st.top().first;
			ll y2=st.top().second;
			if (x-x2<=y-y2) {
				st.pop(); // bisa ditutup sama point terbaru
			}
			else if (x-x2<=y2-y) { // bisa tertutup sama point lama
				useless=1;
				break;
			}
			else {
				break; // gabsa nutup satu sama lain
			}
		}
		if (useless) continue;
		st.push({x,y});
	}
	cout << st.size() << endl;
}

// bisa pake stack
// soalnya xi <= xi+1
// jd sbnarnya patokan saja sama sblh kirinya gedung terbaru
// kalau point sebuah x,y bisa ditutupi oleh x,y terbaru maka x,y lama dikeluarkan
// jika sebaliknya x,y lama bisa tutupi x,y baru gausah ditambah
// jika sama sama gabisa nutupin maka x,y baru ttp ditambah tp x,y lama tdk diremove
/*
4
1 1
3 2
4 3
5 1
expected ans -> 2
3
3 2
4 3
1 1
expected ans -> 1
5
2 10
3 5
4 9
7 6
9 15
expected ans -> 2
*/
# Verdict Execution time Memory Grader output
1 Correct 1617 ms 217788 KB Output is correct
2 Correct 1551 ms 232816 KB Output is correct
3 Correct 1497 ms 226764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 41 ms 3880 KB Output is correct
15 Correct 43 ms 3660 KB Output is correct
16 Correct 50 ms 4288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1504 ms 151536 KB Output is correct
2 Correct 1513 ms 166600 KB Output is correct
3 Correct 1490 ms 162340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1617 ms 217788 KB Output is correct
2 Correct 1551 ms 232816 KB Output is correct
3 Correct 1497 ms 226764 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 320 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 41 ms 3880 KB Output is correct
18 Correct 43 ms 3660 KB Output is correct
19 Correct 50 ms 4288 KB Output is correct
20 Correct 1504 ms 151536 KB Output is correct
21 Correct 1513 ms 166600 KB Output is correct
22 Correct 1490 ms 162340 KB Output is correct
23 Correct 1770 ms 123148 KB Output is correct
24 Correct 1676 ms 156612 KB Output is correct
25 Correct 1625 ms 142780 KB Output is correct