编程题3:数组平均
没找到AC代码
编程题4:游游的k-好数组
代码
哈希+找规律
t = int(input())
while t>0:
t -= 1
n, k, x = map(int, input().split())
data = list(map(int, input().split()))
count = [0]*k
maxVals = [0]*k
for i in range(n):
count[i%k] += 1
maxVals[i%k] = max(data[i], maxVals[i%k])
sumCount = 0
for i in range(n):
sumCount += maxVals[i%k]-data[i]
if sumCount>x:
print(-1)
else:
ans = 0
x -= sumCount
for i in range(k):
val = maxVals[i]
ans = max(ans, val+x//count[i])
print(ans)