Skip to content

Commit

Permalink
Update 2023.10.12
Browse files Browse the repository at this point in the history
  • Loading branch information
SoulTree-Lovers committed Oct 12, 2023
1 parent a60c614 commit 5ae4c89
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions Silver_I/1474.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# 밑 줄
import sys
input = sys.stdin.readline

n, m = map(int, input().split())

strings = []
total_length = 0

for i in range(n):
temp_string = input().strip()
strings.append(temp_string)
total_length += len(temp_string)

result_string = ""

# m 길이만큼 채우기 위해 필요한 밑줄 수
needed_line = m - total_length

# 문자열 사이를 채울 최소 라인 수
one_line = needed_line // (n - 1)

# 문자열 사이를 최소 라인으로 채우고 남은 라인 수 (더 채워야 할 라인)
add_line = needed_line % (n - 1)

count = n - 1

for i in range(n):
result_string += strings[i]

if count > 0:
result_string += "_" * one_line
count -= 1

if add_line > 0 and i < n - 1 and strings[i+1] > "_":
result_string += "_"
add_line -= 1

if add_line > 0 and add_line >= n - i - 1:
result_string += "_"
add_line -= 1



print(result_string)

0 comments on commit 5ae4c89

Please sign in to comment.