Created
November 24, 2014 12:14
-
-
Save haje01/13fefb126fc551e719e1 to your computer and use it in GitHub Desktop.
손고리즘 - Festival2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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