Skip to content

Commit db6e514

Browse files
Merge pull request #625 from baekhangyeol/main
[백한결] 91차 라이브 코테 제출
2 parents 9267654 + a845dcb commit db6e514

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

live9/test91/문제1/백한결.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
def main():
2+
N = int(input())
3+
A = list(map(int, input().strip().split()))[:N]
4+
5+
A.sort()
6+
7+
left = 0
8+
right = N-1
9+
10+
min_pair = (A[left], A[right])
11+
min_num = float('inf')
12+
13+
while left < right:
14+
sum = A[left] + A[right]
15+
16+
if abs(sum) < abs(min_num):
17+
min_num = sum
18+
min_pair = (A[left], A[right])
19+
20+
elif sum < 0:
21+
left += 1
22+
else:
23+
right -= 1
24+
25+
print(min_pair[0], min_pair[1])
26+
27+
28+
if __name__ == '__main__':
29+
main()

live9/test91/문제2/백한결.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from itertools import *
2+
3+
def main():
4+
N = int(input())
5+
A = list(map(int, input().strip().split()))[:N]
6+
7+
all_p = list(permutations(A))
8+
9+
sum = 0
10+
11+
max_sum = 0
12+
13+
for p in range(len(all_p)):
14+
for i in range(len(all_p[p])-1):
15+
sum += abs(all_p[p][i] - all_p[p][i+1])
16+
17+
if sum > max_sum:
18+
max_sum = sum
19+
20+
sum = 0
21+
22+
print(max_sum)
23+
24+
25+
if __name__ == '__main__':
26+
main()

live9/test91/문제3/백한결.py

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

0 commit comments

Comments
 (0)