์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ/BOJ_Python

[BOJ/Step5] 4344 : ํ‰๊ท ์€ ๋„˜๊ฒ ์ง€ (Python)

NaNaRin๐Ÿ™ƒ 2021. 2. 3. 14:06

www.acmicpc.net/problem/4344

 

4344๋ฒˆ: ํ‰๊ท ์€ ๋„˜๊ฒ ์ง€

๋Œ€ํ•™์ƒ ์ƒˆ๋‚ด๊ธฐ๋“ค์˜ 90%๋Š” ์ž์‹ ์ด ๋ฐ˜์—์„œ ํ‰๊ท ์€ ๋„˜๋Š”๋‹ค๊ณ  ์ƒ๊ฐํ•œ๋‹ค. ๋‹น์‹ ์€ ๊ทธ๋“ค์—๊ฒŒ ์Šฌํ”ˆ ์ง„์‹ค์„ ์•Œ๋ ค์ค˜์•ผ ํ•œ๋‹ค.

www.acmicpc.net


๋ฌธ์ œ

๋Œ€ํ•™์ƒ ์ƒˆ๋‚ด๊ธฐ๋“ค์˜ 90%๋Š” ์ž์‹ ์ด ๋ฐ˜์—์„œ ํ‰๊ท ์€ ๋„˜๋Š”๋‹ค๊ณ  ์ƒ๊ฐํ•œ๋‹ค. ๋‹น์‹ ์€ ๊ทธ๋“ค์—๊ฒŒ ์Šฌํ”ˆ ์ง„์‹ค์„ ์•Œ๋ ค์ค˜์•ผ ํ•œ๋‹ค.

 

์ž…๋ ฅ

์ฒซ์งธ ์ค„์—๋Š” ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค์˜ ๊ฐœ์ˆ˜ C๊ฐ€ ์ฃผ์–ด์ง„๋‹ค.

๋‘˜์งธ ์ค„๋ถ€ํ„ฐ ๊ฐ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋งˆ๋‹ค ํ•™์ƒ์˜ ์ˆ˜ N(1 ≤ N ≤ 1000, N์€ ์ •์ˆ˜)์ด ์ฒซ ์ˆ˜๋กœ ์ฃผ์–ด์ง€๊ณ , ์ด์–ด์„œ N๋ช…์˜ ์ ์ˆ˜๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ์ ์ˆ˜๋Š” 0๋ณด๋‹ค ํฌ๊ฑฐ๋‚˜ ๊ฐ™๊ณ , 100๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™์€ ์ •์ˆ˜์ด๋‹ค.

 

์ถœ๋ ฅ

๊ฐ ์ผ€์ด์Šค๋งˆ๋‹ค ํ•œ ์ค„์”ฉ ํ‰๊ท ์„ ๋„˜๋Š” ํ•™์ƒ๋“ค์˜ ๋น„์œจ์„ ๋ฐ˜์˜ฌ๋ฆผํ•˜์—ฌ ์†Œ์ˆ˜์  ์…‹์งธ ์ž๋ฆฌ๊นŒ์ง€ ์ถœ๋ ฅํ•œ๋‹ค.

 

์˜ˆ์ œ ์ž…๋ ฅ 1

5

5 50 50 70 80 100

7 100 95 90 80 70 60 50

3 70 90 80

3 70 90 81

9 100 99 98 97 96 95 94 93 91

 

์˜ˆ์ œ ์ถœ๋ ฅ 1

40.000%

57.143%

33.333%

66.667%

55.556%


ํ’€์ด

 

# 4344.py

n = int(input())

for i in range(n):
    a = list(map(int, input().split()))
    avg = (sum(a) - a[0]) / a[0]
    count = 0
    for j in a[1:]:
        if j > avg:
            count += 1
    print("%.3f%%" % ((count / a[0]) * 100))