【发布时间】:2018-05-12 14:31:53
【问题描述】:
我有一个工作代码块,但是 HackerEarth 上的在线法官一直返回一个计时错误。我是编码新手,所以我不知道加快代码速度的技巧。任何帮助将不胜感激!
N, Q = map(int, input().split())
#N is the length of the array, Q is the number of queries
in_list =input().split()
#input is a list of integers separated by a space
array = list(map(int, in_list))
from numpy import mean
means=[]
for i in range(Q):
L, R = map(int, input().split())
m= int(mean(array[L-1:R]))
means.append(m)
for i in means:
print(i)
任何建议都会很棒!
【问题讨论】:
标签: python-3.x performance loops io