Skip to content

Instantly share code, notes, and snippets.

@haje01
Created November 24, 2014 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haje01/13fefb126fc551e719e1 to your computer and use it in GitHub Desktop.
Save haje01/13fefb126fc551e719e1 to your computer and use it in GitHub Desktop.
손고리즘 - 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