Skip to content

Commit 217e097

Browse files
committed
boj 20364 부동산 다툼
1 parent 5ef93f7 commit 217e097

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tree/20364.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include <iostream>
2+
#include <algorithm>
3+
#define MAX_N 1<<21
4+
#define MAX_M 200000
5+
using namespace std;
6+
7+
bool visit[MAX_N];
8+
int list[MAX_M];
9+
int N, M;
10+
11+
void func() {
12+
for (int i = 0; i < M; i++) {
13+
int v = 1e9;
14+
for (int j = list[i]; j > 0; j /= 2) {
15+
if (visit[j]) v = min(v, j);
16+
}
17+
18+
if (v == 1e9) {
19+
visit[list[i]] = true;
20+
cout << "0\n";
21+
}
22+
else {
23+
cout << v << '\n';
24+
}
25+
}
26+
}
27+
28+
void input() {
29+
cin >> N >> M;
30+
for (int i = 0; i < M; i++) {
31+
cin >> list[i];
32+
}
33+
}
34+
35+
int main() {
36+
cin.tie(NULL); cout.tie(NULL);
37+
ios::sync_with_stdio(false);
38+
39+
input();
40+
func();
41+
42+
return 0;
43+
}

0 commit comments

Comments
 (0)