본문 바로가기

알고리즘/python

[python/파이썬] 백준 4344 평균은 넘겠지

반응형

[문제 출처]

https://www.acmicpc.net/problem/4344

 

4344번: 평균은 넘겠지

대학생 새내기들의 90%는 자신이 반에서 평균은 넘는다고 생각한다. 당신은 그들에게 슬픈 진실을 알려줘야 한다.

www.acmicpc.net

 

[소스 코드]

 

#4344
import sys
input = sys.stdin.readline

T = int(input())
for i in range(T):
  data = list(map(int,input().split()))
  n = data[0]
  score = data[1:]
  avg = sum(score)/n
  cnt = 0
  for j in score:
    if j > avg:
      cnt += 1

  result = (cnt / n) * 100
  print('%.3f' %result + '%')
반응형