Advertisement
Guest User

Untitled

a guest
Oct 9th, 2015
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. import fileinput
  2.  
  3. times = []
  4. q = -1
  5. for (count, line) in enumerate(fileinput.input()):
  6.     if count == 0:
  7.         n = int(line.strip())
  8.     elif count == 1:
  9.         times = list(map(lambda x: int(x.strip()), line.split(" ")))
  10.         times.insert(0, 0)
  11.         for i in range(1, n + 1):
  12.             times[i] += times[i - 1]
  13.     else:
  14.         s = line.split(" ")
  15.         if len(s) == 1 and q == -1:
  16.             q = int(line)
  17.         elif q != -1:
  18.             if count - 2 > q: break
  19.             (t0, t1) = tuple(map(lambda x: int(x), line.split(" ")))
  20.             time = times[t1] - times[t0 - 1]
  21.             print(time / (t1 - t0 + 1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement