DHistory
[Baekjoon] Sort - 5800 성적 통계 본문
문제
5800번: 성적 통계
첫째 줄에 중덕 고등학교에 있는 반의 수 K (1 ≤ K ≤ 100)가 주어진다. 다음 K개 줄에는 각 반의 학생수 N (2 ≤ N ≤ 50)과 각 학생의 수학 성적이 주어진다. 시험 성적은 0보다 크거나 같고, 100보다
www.acmicpc.net
풀이
import sys
k = int(sys.stdin.readline().rstrip())
classes = []
for _ in range(k):
classes.append(list(map(int, sys.stdin.readline().rstrip().split())))
def solution(classes):
for index, value in enumerate(classes):
value = sorted(value[1:], reverse=True)
max_gap = 0
for i in range(len(value) - 1):
max_gap = max(max_gap, value[i] - value[i + 1])
print('Class {}'.format(index + 1))
print('Max {}, Min {}, Largest gap {}'.format(value[0], value[-1], max_gap))
solution(classes)
채점 결과
'Computer Science > Algorithm' 카테고리의 다른 글
[Baekjoon] Sort, Binary Search - 1920 수 찾기 (0) | 2023.09.09 |
---|---|
[Baekjoon] Sort - 1251 단어 나누기 (0) | 2023.09.08 |
[Baekjoon] Sortt - 11931 수 정렬하기 4 (0) | 2023.09.08 |
[Baekjoon] Sort - 8979 올림픽 (0) | 2023.09.08 |
[Baekjoon] 11728 - 배열 합치기 (0) | 2023.09.08 |