Skip to content

Commit c9b33eb

Browse files
Merge pull request #624 from Yujin-Baek/main
[백유진] 91차 라이브 코테 제출
2 parents db6e514 + e100026 commit c9b33eb

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

live9/test91/문제1/백유진.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
n = int(input())
2+
arr = list(map(int, input().split()))
3+
4+
arr.sort()
5+
6+
start = 0
7+
end = n-1
8+
9+
min = float("inf")
10+
answer = []
11+
12+
while start < end:
13+
cum = arr[start] + arr[end]
14+
if cum == 0:
15+
answer.append([arr[start], arr[end]])
16+
break
17+
elif cum < 0:
18+
if abs(cum) < min:
19+
min = abs(cum)
20+
answer.append([arr[start], arr[end]])
21+
start += 1
22+
else:
23+
if abs(cum) < min:
24+
min = abs(cum)
25+
answer.append([arr[start], arr[end]])
26+
end -= 1
27+
28+
result = answer.pop()
29+
result.sort()
30+
print(*result)
31+

live9/test91/문제2/백유진.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from itertools import permutations
2+
3+
n = int(input())
4+
arr = list(map(int, input().split()))
5+
6+
max = 0
7+
8+
for per in permutations(arr):
9+
cum = 0
10+
for i in range(n-1):
11+
cum += abs(per[i] - per[i+1])
12+
if cum > max:
13+
max = cum
14+
15+
print(max)

live9/test91/문제3/백유진.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
def solution(answers):
2+
answer = []
3+
4+
arr1 = [1, 2, 3, 4, 5]
5+
arr2 = [2, 1, 2, 3, 2, 4, 2, 5]
6+
arr3 = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5]
7+
8+
result1 = 0
9+
result2 = 0
10+
result3 = 0
11+
12+
for idx, ans in enumerate(answers):
13+
print(ans)
14+
if ans == arr1[idx%5]:
15+
result1 += 1
16+
if ans == arr2[idx%8]:
17+
result2 += 1
18+
if ans == arr3[idx%10]:
19+
result3 += 1
20+
21+
max_score = max(result1, result2, result3)
22+
23+
if result1 == max_score:
24+
answer.append(1)
25+
if result2 == max_score:
26+
answer.append(2)
27+
if result3 == max_score:
28+
answer.append(3)
29+
30+
return answer

0 commit comments

Comments
 (0)