8000 Update 1539.cpp · sihyeon-kim/basic-algo-lecture@2fabd59 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2fabd59

Browse files< 8000 /div>
Update 1539.cpp
1 parent 0a19bbb commit 2fabd59

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

0x16/solutions/1539.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Authored by : 0000000000
2-
// Co-authored by : -
3-
// http://boj.kr/e3e56a7a9a8844fdb203b3563575ecc5
2+
// Co-authored by : BaaaaaaaaaaarkingDog
3+
// http://boj.kr/deab7ddf836140578b02643f3f13afb1
44
#include <bits/stdc++.h>
55
using namespace std;
66
using ll = long long;
@@ -9,33 +9,32 @@ int h[250005];
99
set<int> s;
1010
ll res;
1111
int main() {
12-
ios::sync_with_stdio(false); cin.tie(NULL);
13-
12+
ios::sync_with_stdio(0);
13+
cin.tie(0);
14+
1415
int n; cin >> n;
1516
h[0] = 0; s.insert(0);
1617
h[n + 1] = 0; s.insert(n + 1);
17-
18+
1819
n--;
1920
int a; cin >> a; a++;
2021
h[a] = 1; s.insert(a);
2122
res = 1;
22-
23+
2324
while (n--) {
2425
cin >> a; a++;
2526
auto it = s.lower_bound(a);
2627
h[a] = max(h[*prev(it)], h[*it]) + 1;
2728
s.insert(a);
28-
29+
2930
res += h[a];
3031
}
31-
32+
3233
cout << res;
3334
}
3435

3536
/*
3637
A의 높이를 H[A]라 하면, H[A]는
37-
max(H[(A보다 작은 수들 중 최댓값)], H[(A보다 큰 수들 중 최솟값)]) + 1
38-
이 됩니다.
39-
38+
max(H[(A보다 작은 수들 중 최댓값)], H[(A보다 큰 수들 중 최솟값)]) + 1이 됩니다.
4039
Set이 비어 있을 때 처리를 편하게 하기 위해 값에 +1을 해 줬습니다.
4140
*/

0 commit comments

Comments
 (0)
0