We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 319b81b commit 48c9bb6Copy full SHA for 48c9bb6
1 file changed
live12/test123/문제1/박희경.py
@@ -0,0 +1,42 @@
1
+import sys
2
+
3
+input = sys.stdin.readline
4
5
+g = int(input())
6
+p = int(input())
7
8
+gate = [i for i in range(g + 1)]
9
10
+# gi 이하에서 가장 가까운 사용 가능한 지점 찾기
11
+def find(x):
12
+ if gate[x] != x: # 이미 다른 비행기가 도킹한 경우
13
+ gate[x] = find(gate[x])
14
+ return gate[x]
15
16
+def union(x, y):
17
+ x = find(x)
18
+ y = find(y)
19
+ gate[x] = y
20
21
+cnt = 0
22
+for _ in range(p):
23
+ gi = int(input())
24
+ first = find(gi)
25
+ if first == 0: # 도킹 불가
26
+ break
27
+ union(first, first-1)
28
+ cnt += 1
29
30
+print(cnt)
31
32
33
+"""
34
+4
35
+6
36
+2
37
38
+3
39
40
41
42
0 commit comments