Skip to content

Instantly share code, notes, and snippets.

@haje01
Created Nov 24, 2014
Embed
What would you like to do?
손고리즘 - Festival2
def calc_mavg(prc, ft):
t = 0
aprc = []
for p in prc:
t += p
aprc.append(t)
n = len(prc)
ma = 100 * n
for s in xrange(0, n - ft + 1):
i = s - 1
sb = aprc[i] if i >= 0 else 0
for e in xrange(s + ft, n + 1):
_as = aprc[e - 1] - sb
a = _as / float(e - s)
if a < ma:
ma = a
return ma
if __name__ == "__main__":
c = int(raw_input())
for i in xrange(c):
_, l = [int(i) for i in raw_input().strip().split()]
prc = [int(i) for i in raw_input().strip().split()]
print "%.11f" % calc_mavg(prc, l)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment