Tiny Bunny
본문 바로가기
Algorithm/Baekjoon

[20044] Project Teams / 파이썬

by LILIRU 2023. 1. 26.

문제

시간제한 / 메모리 제한

입/출력

예제

알고리즘 분류

풀이

  • 전체 학생 수는 무조건 짝수
  • 학생들의 코딩 실력을 오름차순으로 정렬한다.
  • 제일 못하는 학생과 제일 잘하는 학생의 코딩력을 더해서 새로운 배열에 저장한다.
  • pop으로 빼주기 때문에 for문 범위는 N만큼
  • 가장 적은 코딩력의 합 출력

코드

import sys 
input = sys.stdin.readline

N = int(input())
students = list(map(int, input().split()))
sorted_students = sorted(students)
coding_power = []

for i in range(N):
    coding_power.append(sorted_students.pop(0) + sorted_students.pop(-1))

print(min(coding_power))

 

쉬운 문제 풀어버렸다 헤헷 >_0

'Algorithm > Baekjoon' 카테고리의 다른 글

[11727] 2xn 타일링 / 파이썬  (0) 2023.05.27
[18258] 큐 2 / 파이썬  (0) 2023.01.28
[15650] N과 M (2) / 파이썬  (1) 2023.01.27

댓글