Task: | Approximate |
Sender: | Verto |
Submission time: | 2016-05-28 11:25:47 +0300 |
Language: | Python2 |
Status: | READY |
Result: | TIME LIMIT EXCEEDED |
test | verdict | time | |
---|---|---|---|
#1 | TIME LIMIT EXCEEDED | -- | details |
Code
import sys lines = sys.stdin.readlines() def asints(s): return [int(x.strip()) for x in s.split()] n, q = asints(lines[0]) sequence = asints(lines[1]) for i in range(2, q + 2): low, high = asints(lines[i]) subs = sequence[low-1:high] avg = sum(subs) *1.0 / len(subs) errs = [(x*1.0-avg)**2 for x in subs] print sum(errs) / len(errs)