We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bee03d8 commit 2a064b3Copy full SHA for 2a064b3
minjeong/Simulation/2025-01-25-[백준]-#1138-한줄로서기.py
@@ -0,0 +1,25 @@
1
+import sys
2
+
3
+input = sys.stdin.readline
4
5
+# 입력 받기
6
+N = int(input()) # 사람 수
7
+taller = list(map(int, input().split())) # 각 사람이 기억하는 왼쪽 큰 사람의 수
8
9
+# 결과 리스트 초기화
10
+result = [None] * N
11
12
+# 키가 작은 사람(1부터 N까지)을 처리
13
+for i in range(1, N + 1): # i는 현재 사람의 키
14
+ count = taller[i - 1] # 현재 사람이 기억하는 왼쪽 큰 사람의 수
15
+ idx = 0 # result에서 위치를 찾기 위한 인덱스
16
17
+ while count > 0 or result[idx] is not None: # 빈 자리가 아니고 count가 남아있다면 이동
18
+ if result[idx] is None: # 빈 자리일 경우에만 count 감소
19
+ count -= 1
20
+ idx += 1 # 다음 자리로 이동
21
22
+ result[idx] = i # 적절한 자리에 현재 사람 배치
23
24
+# 결과 출력
25
+print(*result)
0 commit comments