8000 Merge pull request #269 from hehehwang/0x16-21939 · Dolarge/basic-algo-lecture@f12bfec · GitHub
[go: up one dir, main page]

Skip to content

Commit f12bfec

Browse files
Merge pull request encrypted-def#269 from hehehwang/0x16-21939
(0x16 이진 검색 트리) Update 21939.cpp
2 parents cfa49d0 + 4c287ce commit f12bfec

File tree

1 file changed

+41
-4
lines changed

1 file changed

+41
-4
lines changed

0x16/solutions/21939.cpp

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,48 @@
1-
// Authored by : BaaaaaaaaaaarkingDog
1+
// Authored by : heheHwang
22
// Co-authored by : -
3-
// http://boj.kr/****************
3+
// http://boj.kr/b08e041f30cd4b509604d115173e4fd9
44
#include <bits/stdc++.h>
55
using namespace std;
66

7-
int main(void){
7+
string op;
8+
int N, L, P, x;
9+
int probLevel[100'002]; // 이 문제가 어느 난이도였는지 저장
10+
set<int> probByLevel[102]; // 난이도별로 문제 저장
11+
int main(void) {
812
ios::sync_with_stdio(0);
913
cin.tie(0);
10-
14+
15+
cin >> N;
16+
while (N--) {
17+
cin >> P >> L;
18+
probLevel[P] = L;
19+
probByLevel[L].insert(P);
20+
}
21+
cin >> N;
22+
while (N--) {
23+
cin >> op;
24+
if (op == "recommend") {
25+
cin >> x;
26+
if (x == 1) {
27+
for (int i = 100; 0 <= i; i--) {
28+
if (probByLevel[i].empty()) continue;
29+
cout << *(prev(probByLevel[i].end())) << '\n';
30+
break;
31+
}
32+
} else {
33+
for (int i = 0; i < 101; i++) {
34+
if (probByLevel[i].empty()) continue;
35+
cout << *probByLevel[i].begin() << '\n';
36+
break;
37+
}
38+
}
39+
} else if (op == "add") {
40+
cin >> P >> L;
41+
probLevel[P] = L;
42+
probByLevel[L].insert(P);
43+
} else if (op == "solved") {
44+
cin >> P;
45+
probByLevel[probLevel[P]].erase(P);
46+
}
47+
}
1148
}

0 commit comments

Comments
 (0)
0