[Python] ABC015 B

問題

B – 高橋くんの集計

回答

切り上げ

math.ceil(x)

import math
N = int(input())
A = list(map(int, input().split()))
cnt_bugs = 0
cnt_softwares = 0
for a in A:
cnt_bugs += a
if a > 0:
cnt_softwares += 1
avg_bugs = cnt_bugs / cnt_softwares
print(math.ceil(avg_bugs))
import math N = int(input()) A = list(map(int, input().split())) cnt_bugs = 0 cnt_softwares = 0 for a in A: cnt_bugs += a if a > 0: cnt_softwares += 1 avg_bugs = cnt_bugs / cnt_softwares print(math.ceil(avg_bugs))
import math

N = int(input())
A = list(map(int, input().split()))

cnt_bugs = 0
cnt_softwares = 0
for a in A:
    cnt_bugs += a
    if a > 0:
        cnt_softwares += 1

avg_bugs = cnt_bugs / cnt_softwares
print(math.ceil(avg_bugs))