Skip to content

Commit d442d6f

Browse files
Merge pull request #613 from Yujin-Baek/main
[백유진] 89차 라이브 코테 제출
2 parents 849c172 + 7b8f28c commit d442d6f

3 files changed

Lines changed: 67 additions & 0 deletions

File tree

live8/test89/문제1/백유진.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
n = int(input())
2+
3+
arr = []
4+
5+
for i in range(n):
6+
arr.append(int(input()))
7+
8+
arr.sort()
9+
10+
start = 0
11+
end = 0
12+
13+
max = float("-inf")
14+
15+
while end < n:
16+
if arr[end] - arr[start] > 4:
17+
start += 1
18+
else:
19+
if end - start + 1 > max:
20+
max = end - start + 1
21+
end += 1
22+
23+
print(5-max)

live8/test89/문제2/백유진.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
n, m = map(int, input().split())
2+
arr = list(map(int, input().split()))
3+
4+
answer = 0
5+
6+
start = 0
7+
end = 0
8+
9+
cum_sum = arr[start]
10+
11+
while end < len(arr):
12+
if cum_sum == m:
13+
answer += 1
14+
cum_sum -= arr[start]
15+
start += 1
16+
elif cum_sum < m:
17+
end += 1
18+
if end < len(arr):
19+
cum_sum += arr[end]
20+
else:
21+
cum_sum -= arr[start]
22+
start += 1
23+
24+
print(answer)

live8/test89/문제3/백유진.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from functools import cmp_to_key
2+
3+
def max_num(a, b):
4+
if a+b > b+a:
5+
return -1
6+
elif b+a > a+b:
7+
return 1
8+
return 0
9+
10+
def solution(numbers):
11+
sarr = list(map(str, numbers))
12+
13+
# 정렬 기준: 두 수를 이어붙였을 때 큰 순서대로 정렬
14+
sarr.sort(key=cmp_to_key(max_num))
15+
16+
# 만약 가장 큰 숫자가 0이면 전체가 0이므로 '0' 반환
17+
if sarr[0] == "0":
18+
return "0"
19+
20+
return "".join(sarr)

0 commit comments

Comments
 (0)