Skip to content

Commit

Permalink
내 집 마련하기 풀이
Browse files Browse the repository at this point in the history
  • Loading branch information
westreed committed Apr 3, 2024
1 parent 3d65152 commit 1ac9a7d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions BAEKJOON/2Silver/내 집 마련하기.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 구현, 정렬
# https://www.acmicpc.net/problem/30619

"""
5
1 3 4 2 5
3
2 3
3 5
1 5
"""

if __name__ == "__main__":
N = int(input())
house = list(map(int, input().split()))

Q = int(input())
for _ in range(Q):
L, R = map(int, input().split()) # 사람번호임 house의 값
_house = house[:]
_cache1 = []
_cache2 = []

# O(n)
for i in range(N):
if L <= _house[i] <= R:
_cache1.append(_house[i])
_cache2.append(i)

_cache1.sort()
for i, idx in enumerate(_cache2):
_house[idx] = _cache1[i]
print(*_house)

0 comments on commit 1ac9a7d

Please sign in to comment.