Problem:


Score : 400 points

Problem Statement

We have N dice arranged in a line from left to right. The i-th die from the left shows p_i numbers from 1 to p_i with equal probability when thrown.

We will choose K adjacent dice, throw each of them independently, and compute the sum of the numbers shown. Find the maximum possible value of the expected value of this sum.

Constraints

1 ≤ K ≤ N ≤ 200000

1 ≤ p_i ≤ 1000

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
p_1 ... p_N

Output

Print the maximum possible value of the expected value of the sum of the numbers shown.

Your output will be considered correct when its absolute or relative error from our answer is at most 10^{-6}.

Sample Input 1

5 3
1 2 2 4 5

Sample Output 1

7.000000000000

When we throw the third, fourth, and fifth dice from the left, the expected value of the sum of the numbers shown is 7. This is the maximum value we can achieve.

Sample Input 2

4 1
6 6 6 6

Sample Output 2

3.500000000000

Regardless of which die we choose, the expected value of the number shown is 3.5.

Sample Input 3

10 4
17 13 13 12 15 20 10 13 17 11

Sample Output 3

32.000000000000



Sample input:
5 3
1 2 2 4 5


Sample output:
7.000000000000

Submission status: Runtime Error

Solution code:
N,K = map(int, input().split())
pi = list(map(int, input().split()))
#期待値列
E=[(p+1)/2 for p in pi]
F=[]
for i in range(N-K+1):
  for j in range(K):
  	F[i]=F[i]+E[i+j]
print(str(max(F)/K))

Submission status: Runtime Error

Solution code:
N, K = input().split(" ")
N, K = int(N), int(K)
p_list = [int(i) for i in input().split(" ")]

for i in range(0, N):
  if (i+K > N) or (p_list[i-1] >= p_list[i-1+K]):
    break

  if i == 0:
    max_sum = sum(p_list[0:K])+K
  else:
    tmp = sum(p_list[i:i+K])+K
    if max_sum < tmp:
      max_sum = tmp

print(max_sum/2)

Submission status: Runtime Error

Solution code:
import numpy as np

first_int = [int(k) for k in input().split()]
a = first_int[0]
b = first_int[1]
secound_list = [int(k) for k in input().split()]

import numpy as np

first_int = [int(k) for k in input().split()]
a = first_int[0]
b = first_int[1]
secound_list = [int(k) for k in input().split()]

def sigm(k):
  return np.sum(np.array(range(k+1)))/k

all_sigm = [sigm(k) for k in secound_list]

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
l = input().split()
l = [(int(i)+1)/2 for i in l]
sum3 = []
for i in range(n-k):
    sum = 0
    m = l[0]+l[1]+l[2]
    for j in range(k):
        sum += l[i+j]
        #sum3.append(sum)
    if sum > m:
        m = sum
    print(m)
#m = max(sum3)

print(m)

Submission status: Runtime Error

Solution code:
#At coder 2020/2/9 D

# 入力
N,K= map(int, input().split())
p = list(map(int, input().split())) 
#p2 = sorted(p, reverse=True)
#print(p2)
kk=[0] * (N-K+1)

if N==K:
    kk=sum(p)
else:
    for ii in range(N-K+1):
        kk[ii]=sum(p[ii:K+ii])
kk=max(kk)
K=float(K)
kk=float(kk)
ans=0.5*(kk+K)

print(ans)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
ans = []
for i in range(1, n-k+1):
    ans.append(sum(p[(i):(k+i)]))
print(print((k+max(ans))/2))

Submission status: Runtime Error

Solution code:
N, K = map(int,input().split())
p = list(map(int,input().split()))

#累積和を前計算
sum_list = [0 for _ in range(1001)]
sum = 0

for i in range(len(p)):
    sum += p[i]
    sum_list[i] = sum

#答えを計算
mev = 0
idx = 0
for i in range(N-K+1):
    ev = sum_list[i+K]-sum_list[i]
    if ev > mev:
        idx = i
        mev = ev

mev = 0
for i in range(idx+1,idx+1+K):
    mev += (p[i] + 1.0) / 2.0

print(mev)

Submission status: Runtime Error

Solution code:
def main():
    n, k = map(int, input().split())
    l = [i for i in map(int, input().split())]
    items = []
    for i in range(n-k):
      items += sum(l[i:i+k]),
    print((max(items)+k)/2)


main()

Submission status: Runtime Error

Solution code:
def main(n, k, p: list):
    ans = 0

    memo = defaultdict(int)

    for i in range(n - k + 1):

        t = 0
        for j in p[i : i + k]:
            if memo[j] == 0:
                for _k in range(1, j + 1):
                    t += _k * (1 / j)
            else:
                t = memo[j]

        ans = max(ans, t)

    print("{:06f}".format(ans))


if __name__ == "__main__":
    n, k = map(int, input().split())
    p = list(map(int, input().split()))

    main(n, k, p)

Submission status: Runtime Error

Solution code:
from itertools import accumulate
import numpy as np
N, K = list(map(int, input().split()))
A = np.array(list(map(int, input().split())))
A = (A+1)/2

B = np.insert(A,0,0)
B = list(accumulate(B))
answer = []
for i in range(N-K):
    answer.append(B[i+K]-B[i])

print(max(answer))

Submission status: Runtime Error

Solution code:
N, K = input().split(" ")
N, K = int(N), int(K)
P = input().split(" ")
P = [int(p) for p in P]
 
max_ = None
sum_max = None
for i in range(N-K):
	cur = P[i:i+K]
	sum_cur = sum(cur)
	if sum_max is None or sum_cur > sum_max:
		max_ = cur
		sum_max = sum_cur
result = 0
for ele in max_:
	result += (ele+1)/2.
print(result)

Submission status: Runtime Error

Solution code:
N,K = map(int, input().split())
l = list(map(int,input().split()))

def E(n):
  return sum(range(1,n+1)) / n

j = sum(l[0:0+K])
m = 0
if N == 1:
  l2 = list(map(E, l))
  print(sum(l2))
  
else:
  for i in range(1,len(l)-(K-1)):
      j = j - l[i-1] + l[i+K-1]
      if l[i] < l[i-1]:
          continue
      elif m < j:
          m = j
          t = l[i:i+K]

  l2 = list(map(E, t))

  print(sum(l2))

Submission status: Runtime Error

Solution code:
import numpy as np
n,k = list(map(int,input().split()))
p = np.array(list(map(int,input().split())))

P = 0
for i in range(n-k):
  if P < p[i:i+k].sum():
    P = p[i:i+k].sum()
    mp = p[i:i+4]

ans = 0
for i in mp:
  if i%2 == 0:
    ans += ((i+1) * i//2)/i
  else:
    ans += ((i+1) * (i//2) + (i//2) + 1)/i
print(ans)

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
P = list(map(int,input().split()))
for i in range(N):
    ans = max(P[i]//0 for j in range(P[i])+P[i+1]//0 for j in range(P[i+1])+P[i+2]//0 for j in range(P[i+2]))
print(ans)

Submission status: Runtime Error

Solution code:
def main():
    n, k = map(int, input().split())
    l = [i for i in map(int, input().split())]
    items = []
    for i in range(n-k):
      items += sum(l[i:i+k]),
    print((max(items)+k)/2)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
P = list(map(int,input().split()))
dp = []*N+1
dp[0] = 0
for i in range(N):
    ans = max(P[i]//0 for j in range(P[i])+P[i+1]//0 for j in range(P[i+1])+P[i+2]//0 for j in range(P[i+2]))
print(ans)

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
P=list(map(int,input().split()))


maxnum=0
index=0
num=0
for i in range(len(P)-2):
    num+=P[i]



    if maxnum<num:
        maxnum=num
        index=i

    if i>=K:
        num-=P[i-(K-1)]
List=[]

for i in range(K):
    x1=P[index+i]
    sumx1=0
    for j in range(1,x1+1):
        sumx1+=j

    sumx1=sumx1/x1
    List.append(sumx1)


print(sum(List))

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
ps = list(map(int, input().split()))
Es = [sum(range(1, ps[i]+1))/ps[i] for i in range(N)]
maxs = []
for i in range(N):
  if i<K:
    continue
  else:
    maxs.append(sum(Es[i-K:i]))
print(max(maxs))

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
px = [(1 + p[i])/2 for i in range(n)]

ans = sum(px[0: 0 + k])
bef = sum(px[0: 0 + k])
for i in range(i, n - k + 1):
    bef = bef-px[i-1]+px[i+k-1]
    ans = max(ans, bef)
print(ans)

Submission status: Runtime Error

Solution code:
# A = input()
# A = int(input())
# A = map(int, input().split())
# A = list(map(int, input().split()))
# A = [int(input()) for i in range(N)]
#
# c = collections.Counter()

import collections

N, K = list(map(int, input().split()))
p = list(map(int, input().split()))

ma = sum(p[:K])
idx = 0

kukan = [sum(p[i:i+K]) for i in range(N-K)]
idx = kukan.index(max(kukan))

ans = 0
for i in range(K):
  ans += sum(list(range(1, p[idx+i]+1)))/p[idx+i]

print(ans)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
px = [(1 + p[i])/2 for i in range(n)]

ans = sum(px[i: i + k])
bef = sum(px[i: i + k])
for i in range(i, n - k + 1):
    bef = bef-px[i-1]+px[i+k-1]
    ans = max(ans, bef)
print(ans)

Submission status: Runtime Error

Solution code:
N, K = input().split(" ")
N, K = int(N), int(K)
P = input().split(" ")
P = [int(p) for p in P]
 
max_ = None
sum_max = None
for i in range(N-K):
	cur = P[i:i+K]
	sum_cur = sum(cur)
	if sum_max is None or sum_cur > sum_max:
		max_ = cur
		sum_max = sum_cur
result = 0
for ele in max:
	result += (ele+1)/2.
print(result)

Submission status: Runtime Error

Solution code:
def E(n):
  return n*(1+n)/2/n

n, k = map(int, input().split())
l = list(map(int, input().split()))
ex = []
exsum = [0] *20000

tmpmax = 0
for i in range(n):
  ex.append(E(l[i]))

for i in range(n-k+1):
  if i == 0:
    for j in range(k):
      tmpmax += ex[i+j]
      exsum[i] = tmpmax
  else:
    exsum[i] = exsum[i-1] - ex[i-1] + ex[i+k-1]
  
a = exsum.index(max(exsum))

print(exsum[a])

Submission status: Runtime Error

Solution code:
n, k = [int(i) for i in input().split()]
p = [int(j) for j in input().split()]

exp = 0e0
max = 0e0
maxi = -1

#for l in range(n):
    #print(p[-(l+1)])
    #exp += (0.5*p[-(l+1)]*(p[-(l+1)]+1))/p[-(l+1)]
    #p[l] = 0.5*(p[l]+1)

for l in range(n-k):
    exp = 0
    for m in range (l, l+k)
        exp += p[m]
        if(exp > max):
            max = exp
            maxi = l

out = 0
for aa in range (maxi,maxi+k):
    out += 0.5*(p[aa]+1)

print(out)

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
ans=[sum(p[0:k])]
  ans.append(ans[i-1]+p[i+k-1]-p[i-1])
max_value=max(ans)
max_index=ans.index(max_value)
total=0
for i in p[max_index:max_index+k]:
  total+=(i+1)/2
print(total)

Submission status: Runtime Error

Solution code:
N, K = input().split(" ")
N, K = int(N), int(K)
P = input().split(" ")
P = [int(p) for p in P]
 
max_ = None
sum_max = None
for i in range(N-K):
	cur = P[i:i+K]
    sum_cur = sum(cur)
	if sum_max is None or sum_cur > sum_max:
		max_ = cur
        sum_max = sum_cur
result = 0
for ele in max:
	result += (ele+1)/2.
print(result)

Submission status: Runtime Error

Solution code:
N,K = map(int, input().split())
l = list(map(int,input().split()))

j = sum(l[0:0+K])
m = 0
for i in range(1,len(l)-(K-1)):
    j = j - l[i-1] + l[i+K-1]
    if l[i] < l[i-1]:
        continue
    elif m < j:
        m = j
        t = l[i:i+K]
        
def E(n):
    return sum(range(1,n+1)) / n

l2 = list(map(E, t))

print(sum(l2))

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
P = list(map(int, input().split()))

ans = -1
memo = [-1]*(K-1)

for memo_i in range(K-1):
    memo[memo_i] = P[memo_i]

for i in range(K-1, N):
    sum_ = sum(memo) + P[i]
    ans = max(ans, sum_)
    memo.pop(0)
    memo.append(P[i])

tmp = ans - K + 1
print(K-1+(tmp - 0.5*(tmp-1)))

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
p_list = list(map(int,input().split()))
ruiseki = []
a = 0
for i in range(n):
  a += p_list[i]
  ruiseki.append(a)
res = -1
val_list = []
for m in range(n-k):
  val = ruiseki[k+m] - ruiseki[m]
  val_list.append(val)
print((max(val_list)+k)/ 2)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

def f(x):
    if x == 1:
        return 1
    else:
        return f(x-1) + x

[N, K] = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]

max_index = 0
max_sum = 0
for i in range(len(P)-(K-1)):
    sum_P = sum(P[i:i+K])
    if sum_P > max_sum:
        max_sum = sum_P
        max_index = i

#print(max_sum)
#print(max_index)

# 隣接したK個のリスト
kk = P[max_index:max_index+K]

# kの期待値を計算
#max_kk = max(kk)
#dp = [0]
#for i in range(1, max_kk+1):
#    dp.append(dp[i-1] + i)
#print(dp)

ans = 0
for k in kk:
    ans += f(k)/k

print(ans)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))

total_expects = []
# 1回のサイコロについて
for i in range(0, n):    
    # 1個のサイコロの期待値リスト
    expect = [q * (1 / p[i]) for q in range(1, p[i]+1)]
    total_expects.append(sum(expect))

max_k_expect = 0
for i in range(0, k):
    if max_k_expect < sum(total_expects[i:i+k]):
        max_k_expect = sum(total_expects[i:i+k])
print(max_expect)

Submission status: Runtime Error

Solution code:
from itertools import accumulate
import numpy as np
N, K = list(map(int, input().split()))
A = np.array(list(map(int, input().split())))
A = (A+1)/2

B = [0] + A
B = list(accumulate(B))
answer = []
for i in range(N-K):
    answer.append(B[i+K]-B[i])

print(max(answer))

Submission status: Runtime Error

Solution code:
def K(n):
    return 0.5 * (n + 1)

def d():
    n, k = list(map(int, input().split()))
    p = list(map(int, input().split()))

    pionta = None
    ire = [None for i in range(k)]
    for i in range(0, n):
        if k < i + 1:
            pionta = i // k
        if pionta is None:
            ire[i] = p[i]
        else:
            if ire[pionta] < p[i]:
                ire[pionta] = p[i]
    m = 0
    for i in ire:
        m += K(i)
    return m
print(d())

Submission status: Runtime Error

Solution code:
N,K = map(int, input().split())
l = list(map(int,input().split()))

j = sum(l[0:0+K])
m = 0
for i in range(1,len(l)-(K-1)):
    j = j - l[i-1] + l[i+K-1]
    if l[i] =< l[i-1]:
        continue
    elif m < j:
        m = j
        t = l[i:i+K]
        
def E(n):
    return sum(range(1,n+1)) / n

l2 = list(map(E, t))

print(sum(l2))

Submission status: Runtime Error

Solution code:
#include<iostream>
#include<vector>
using namespace std;

int main() {
	int n,k; cin >> n >> k;
	vector<int>a(n); for (auto&& x : a)cin >> x;
	int b = 0,c = 0;
  	double ans = 0.0;
  
  	for (int i = 0; i < (n - k +1); i++){
      int sum = 0;
      for (int j = 0;j < k;j++){
      	sum+=a[i+j];
      }
    	if (b < sum){
          b=sum;
          c=i;
        }
    }
  	for (int z =0; z < k;z++){
    	ans+=(double)(a[c+z]+1)/2.0;
    }
 	cout << ans << endl;
	return 0;
}

Submission status: Runtime Error

Solution code:
import math
from functools import lru_cache

@lru_cache(maxsize=500)
def d(p):
    if p <= 1:
        return 1
    else:
        return p + d(p - 1)

n, k = [int(x) for x in input().split()]
pp = input()
p = []
maxx = 0
f = 0
for x in pp.split():
    xx = int(x)
    p.append(d(xx) / xx)
    if len(p) >= k:
        summ = sum(p[f:f + k])
        if summ > maxx:
            maxx = summ
        f += 1
print(maxx)

Submission status: Runtime Error

Solution code:
import numpy as np

NK = input().split()
N = int(NK[0])
K = int(NK[1])
P = input().split()
P = np.array([int(p) for p in P])
wa = P*(P+1)/2

s = wa/P
s_list = np.array([s[i:K+i] for i in range(N-K+1)])
s2 = s_list.sum(axis=1)
print(np.max(s2))

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
l=list(map(int,input().split()))

for i in range(n-k):
    if sum(l[i:i+k]) < sum(l[i+1:i+k+1]):
        max=l[i+1:i+k+1]
    else:
        max=l[i:i+k]

result=float(0)
for i in range(len(max)):
    t=max[i]
    if t%2==0:
        result += (1+t)*(t/2)/t
    else:
        result += ((1+t)*(t//2)+(t//2+1))/t
    
print(result)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
nxt = 0.000000000001
mx = []
for i in range(n):
    pex = (1+p[i]+0.000000000001)/2
    mx.append(pex+nxt)
    nxt = pex + nxt
ans = []
for i in range(n-k):
    ans.append(mx[i+k] - mx[i])
print(max(ans))

Submission status: Runtime Error

Solution code:
N = int(input())
K = int(input())
p[N] = int(input().split())

ans = 0
e_sum = 0

for j in range(K):
  e_sum = e_sum + (p[j]+1)/2

ans = e_sum
for i in range(K,N):
  e_sum = e_sum + (p[i]+1)/2
  e_sum = e_sum - (p[i-K]+1)/2
  if ans<e_sum:
    ans=e_sum

print(ans)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
nxt = 0.000000000001
mx = []
for i in range(n):
    pex = (1+p[i])/2+0.000000000001
    mx.append(pex+nxt)
    nxt = pex + nxt
ans = []
for i in range(n-k):
    ans.append(mx[i+k] - mx[i])
print(max(ans))

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
l = [i for i in map(int, input().split())]
items = []
for i in range(n-k):
  items += sum(l[i:i+k]),
print((max(items)+k)/2)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
nxt = 0.000000000001
mx = []
for i in range(n):
    pex = (1+p[i])/2
    mx.append(pex+nxt+0.000000000001)
    nxt = pex + nxt
ans = []
for i in range(n-k):
    ans.append(mx[i+k] - mx[i]+0.000000000001)
print(max(ans))

Submission status: Runtime Error

Solution code:
from itertools import accumulate

N, K = list(map(int, input().split()))
C = list(map(int, input().split()))
A=[]
for i in range(N):
  A.append((C[i]+1)/2)
B = [0] + A
B = list(accumulate(B))

ans = []
for i in range(N-K):
    ans.append(B[i+K]-B[i])

print(max(ans))

Submission status: Runtime Error

Solution code:
import numpy as np

N, K = map(int, input().split())
p = list(map(int, input().split()))

pos = 0
saidai = 0
for i in range(N-K+1):
  temp = sum(p[i:i+K])
  if saidai < temp:
    saidai = temp
    pos = i
    
kitaichi = 0
for i in range(K):
  temp = (p[pos+i]+1)*p[pos+i]/2
  kitaichi = kitaichi + float(temp/p[pos+i])
  
print('{:.12f}'.format(kitaichi))

Submission status: Runtime Error

Solution code:
def sigma(n):
    return sum([i for i in range(n+1)])

def main():
    N, K = map(int, input().split(' '))
    p = list(map(int, input().split(' ')))

    max_value = 0
    for i in range(N-K+1):
        sum_ = sum(p[i:i+K-1])
        if sum_ > max_value:
            max_value = sum_
            max_list = p[i:i+K]

    expected = 0
    for v in max_list:
        expected += sigma(v) / v

    print(expected)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
l=list(map(int,input().split()))

for i in range(n-k):
    if sum(l[i:i+k]) < sum(l[i+1:i+k+1]):
        max=l[i+1:i+k+1]
    else:
        max=l[i:i+k]

result=float(0)
for i in range(len(max)):
    t=max[i]
    if t%2==0:
        result += (1+t)*(t/2)/t
    else:
        result += ((1+t)*(t//2)+(t//2+1))/t
    
    print(result)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
ps = list(map(int, input().split()))
Es = [sum(range(1, ps[i]+1))/ps[i] for i in range(N)]
maxs = []
for i in range(N):
  if i<K:
    continue
  else:
    maxs.append(sum(Es[i:i+K]))
print(max(maxs))

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(x for x in input().split())
if len(a) == len(list(set(a))):
    print('YES')
else:
    print('NO')

Submission status: Runtime Error

Solution code:
import numpy as np

NK = input().split()
N = int(NK[0])
K = int(NK[1])
P = input().split()
P = np.array([int(p) for p in P])
wa = P*(P+1)/2

s = wa/P
s_list = np.array([s[i:K+i] for i in range(N-K+1)])
s2 = s_list.sum(axis=1)
s2 = np.sort(s2)
print(s2[-1])

Submission status: Runtime Error

Solution code:
def E(n):
  return n*(1+n)/2/n

n, k = map(int, input().split())
l = list(map(int, input().split()))
ex = []
exsum = [0] *20000

tmpmax = 0
for i in range(n):
  ex.append(E(l[i]))

for i in range(n-k+1):
 for j in range(k):
  if i == 0:
    tmpmax += ex[i+j]
    exsum[i] = tmpmax
  else:
    exsum[i] = exsum[i-1] - ex[i-1] + ex[i+k-1]
a = exsum.index(max(exsum))

print(exsum[a])

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
p = list(map(int,input().split()))
e = [0]*n

e[0] = (p[0]+1.0)/2.0
e[1] = (p[1]+1.0)/2.0
emax = 0

for i in range(2,n) :
    e[i] = (p[i] + 1.0)/2.0
    enow = sum(e[i-k+1:i+1])
    emax = max(enow,emax)

print(emax)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
nxt = 0
mx = []
for i in range(n):
    pex = (1+p[i])/2
    mx.append(pex+nxt)
    nxt = pex + nxt
ans = []
for i in range(n-k):
    ans.append(mx[i+k] - mx[i])
print(max(ans)+0.000000000001)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
max_val = 0
temp = 0
index = 0

for i in range(0, N-K+1):
    for j in range(i, i+K):
        temp += (p[j]+1)/2
    if max_val < temp:
        max_val = temp
        index = i
    temp = 0

print(sum_value)

Submission status: Runtime Error

Solution code:

def Main(N, K, P):
    wa = sum(P[:K])
    max_sum = wa
    max_sum_ind = 0
    for i in range(N-K-1):
        wa = wa - P[i] + P[i+K]
        if(wa > max_sum):
            max_sum = wa
            max_sum_ind = i
    ans = 0
    for i in range(max_sum_ind+1, max_sum_ind+K+1):
        ans += (P[i]+1)/2
    return ans

def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    print("{:.12f}".format(Main(N, K, P)))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n,k = input().split()
N = int(n)
K = int(k)
pi = list(map(int, input().split()))
#期待値列
E=[(p+1)/2 for p in pi]
F=[]
for i in range(N-K):
  for j in range(K):
  	F[i]=E[1+i+j]
print(str(max(F)/K))

Submission status: Runtime Error

Solution code:
from collections import deque
n, k = map(int, input().split())
P = deque(map(int, input().split()))

s_max = 0
popped = 0
P_max = deque([])
for i in range(k):
    popped = P.popleft()
    P_max.append(popped)
    s_max += popped
s = s_max
# print(s)
P_extracted = P_max.copy()
while P != deque([]):
    # print(P_extracted, P, P_max)
    s -= P_extracted.popleft()
    popped = P.popleft()
    s += popped
    # print(s)

    # P_extracted.popleft()
    P_extracted.append(popped)
    # print(P_extracted)
    if s_max < s:
        s_max = s
        P_max = P_extracted.copy()
        # print(s_max, P_max)

# print(s_max, P_max)
e = 0
for i in P_max:
    tmp = 0
    for j in range(1, i+1):
        tmp += j / i
    # print(tmp)
    e += tmp
print(e)

Submission status: Runtime Error

Solution code:
import numpy as np
from numba import njit

@njit
def resolve():
    n, k = map(int, input().split())
    p = np.array(list(map(int, input().split())))

    sums = [0] * (n-k+1)
    i = 0
    while i < k:
        if k-i > 1:
            sums += p[i:(k-i-1) * -1]
            i += 1
        else:
            sums += p[i:]
            i += 1

    print((np.max(sums) + k) / 2)

resolve()

Submission status: Runtime Error

Solution code:
from itertools import accumulate
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

B = [0] + A
B = list(accumulate(B))
answer = []
for i in range(N-K):
    answer.append(B[i+K]-B[i])
    
print(max(answer))

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
l = input().split()
l = [(int(i)+1)/2 for i in l]
sum3 = []
for i in range(n-k):
    sum = 0
    for j in range(k):
        sum += l[i+j]
        sum3.append(sum)
m = max(sum3)

print(m)

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
kouho=[]
def saikorokitaiti(A):
    return ((P[A]*(1+P[A])/2)/P[A])
kari=[]
hako=[]
for i in range(N-K+1):
    if i == 0:
        for j in range(K):
            hako.append(saikorokitaiti(i+j))
        if K==1:
            print(sum(hako))
            exit()
    else:
        hako.append(saikorokitaiti(i+K-1))
        hako.pop(0)
        kouho.append(sum(hako))

print(max(kouho))

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
P = list(map(int,input().split()))
dp = []*N+1
dp[0] = 0
for i in range(N):
    dp[i+1] = max(dp[i]//P[i],dp[i+1]//P[i+1])
hope = max(dp[i:i+3])
hopes = sum(hope)

Submission status: Runtime Error

Solution code:
import numpy as np

NK = input().split()
N = int(NK[0])
K = int(NK[1])
P = input().split()
P = np.array([int(p) for p in P])
wa = P*(P+1)/2

s = wa/P
s_list = np.array([s[i:K+i] for i in range(N-K+1)])
s2 = s_list.sum(axis=1)
print(s2)
s2 = np.sort(s2,kind='quick_sort')
print(s2[-1])

Submission status: Runtime Error

Solution code:
N, K = input().split(" ")
N, K = int(N), int(K)
P = input().split(" ")
P = [int(p) for p in P]

max = None
for i in range(N-K):
	cur = P[i:i+K]
	if max is None or sum(cur) > sum(max):
		max = cur
result = 0
for ele in max:
	result += (ele+1)/2.
print(result)

Submission status: Runtime Error

Solution code:
N, K = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
    
    
s = [0] * (N-K)

for i in range(N-K):
    s[i] = 0
    for j in range(K):         
      s[i] += p[i+j]# /2+0.5

print( (max(s))/2+0.5*K)

Submission status: Runtime Error

Solution code:
import numpy as np

N, K = map(int, input().split())
nums = [int(i) for i in input().split()]


def hoge(ls):
    e_value = 0
    for l in ls:
        e_value += np.arange(1, l+1).sum() / l
    return e_value


ans = 0
for i in range(N-K+1):
    tmp = nums[i:i + K]
    max_tmp = hoge(tmp)
    if max_tmp > ans:
        ans = max_tmp
print(ans)

Submission status: Runtime Error

Solution code:
a = [int(b) for b in input().split()]
l = input().split()
l = [int(n) for n in l]



ret = 0

ret = [0.5*(sum(l[i:i+a[1]])+a[1]) for i in range(a[0] - a[1])]

print(max(ret))

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
cnt=0
tmp=0
ans=0
count=0
for i in range(N-K+1):
	#print(P[i:i+K])
	if cnt<sum(P[i:i+K]):
		cnt=sum(P[i:i+K])
		tmp=i
Q=P[tmp:tmp+K]
count=collections.Counter(Q)
C_K=list(count.keys())
C_V=list(count.values())
R=len(count)
for i in range(R):
	ans+=(C_K[i]*(C_K[i]+1)/(2*C_K[i])*C_V[i])
print(ans)

Submission status: Runtime Error

Solution code:

def Main(N, K, P):
    wa = sum(P[:K])
    max_sum = wa
    max_sum_ind = 0
    for i in range(N-K):
        wa = wa - P[i] + P[i+K]
        if(wa > max_sum):
            max_sum = wa
            max_sum_ind = i
    ans = 0
    for i in range(max_sum_ind+1, max_sum_ind+K+1):
        ans += (P[i]+1)/2
    return ans

def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    print("{:.12f}".format(Main(N, K, P)))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n,m=(int(i) for i in input().split())
a=[0 for i in range(n-m+1)]
for i in input().split():
  a[i:i+m]+=((int(i)+1)/2)
print(max(a))

Submission status: Runtime Error

Solution code:
import numpy as np

N,K=map(int,input().split())
p=np.zeros(N)
p=list(map(int, input().split()))

max=0
for i in range(len(p)-K+1):
    #print("i="+str(i))
    all=0.0
    for j in range(i,i+K):
        #print(((p[j]*(p[j]+1))/2)/p[j])
        all+=((p[j]*(p[j]+1))/2)/p[j]

    if max<all:
        max=all

print(max)

Submission status: Runtime Error

Solution code:
n, k = [int(i) for i in input().split()]
p = [int(j) for j in input().split()]

exp = 0e0
max = 0e0
maxi = -1

#for l in range(n):
    #print(p[-(l+1)])
    #exp += (0.5*p[-(l+1)]*(p[-(l+1)]+1))/p[-(l+1)]
    #p[l] = 0.5*(p[l]+1)

for m in range (n-k):
    exp = 0e0
    for n in range(m, m+k):
        exp += p[n]
    if(exp > max):
        max = exp
        maxi = n

out = 0
for aa in range (maxi,maxi+k):
    out += 0.5*(p[aa]+1)

print(out)

Submission status: Runtime Error

Solution code:
import numpy as np
from numba import njit

@njit
def process(c,m):
    return np.convolve(0.5*(candidates+1), np.ones(m))

n, m = map(int, input().split())

candidates = np.array(list(map(int, input().split())))
s = process(candidates, m)
print(s.max())

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
p_list = list(map(int,input().split()))
ruiseki = []
a = 0
for i in range(n):
  a += p_list[i]
  ruiseki.append(a)
res = -1
for m in (n-k):
  val = ruiseki[k+i] - ruiseki[i]
  if val > res:
    res = val
print(val)

Submission status: Runtime Error

Solution code:
# きりみんちゃんの配信をみてたので期待値は分かる
# 素直にTLEくらったので累積和で加減する
# え これでもだめなの
# あほだった sumしてるし
# 単純にみたら 0.5ずつ増えてるのでそうするか
# 1WA...
# N = 1の場合か？


n, k = map(int, input().split())
arr = list(map(int, input().split()))
table = {}
ans = 0
for i in range(1, 1000 + 1):
    table[i] = (i + 1) * 0.5
if n == 1:
    print(etable[arr[0]])
    exit()
lis = [0 for _ in range(n)]
lis[0] = table[arr[0]]
for i in range(n - 1):
    if i + 1 < k:
        lis[i + 1] = lis[i] + table[arr[i + 1]]
    else:
        lis[i + 1] = lis[i] + table[arr[i + 1]] - table[arr[i - k + 1]]
    ans = max(ans, lis[i + 1])
print(ans)

Submission status: Runtime Error

Solution code:
x = 0
for i in range(k-1, n):
	s = 0
	tmp = []
	for j in range(i-(k-1), i+1):
		tmp.append(p[j])
		s += p[j]
	if x < s:
		x = s
		y = tmp
		#print(y)#テスト用

ans = 0
for i in y:
	a = 0
	for j in range(1, i+1):
		a += j
	ans += a / i

print(ans)

Submission status: Runtime Error

Solution code:
def resolve():
    n,k = map(int, input().split())
    p = list(map(int, input().split()))
    exp = [0.5*i + 0.5 for i in range(1,1000)]
    arr=[0 for i in range(n)]
    ans=0
    for i,j in enumerate(p):
        arr[i] = exp[j-1]
    for i in range(n-k+1):
        tmp = 0
        for j in range(k):
            tmp += arr[i+j]
        if tmp>ans:
            ans =tmp
    print(ans)
    
if __name__ == "__main__":
    resolve()

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
l = input().split()
l = [int(i) for i in l]
sum3 = []
for i in range(n-k):
    sum = 0
    #print(i)
    for j in range(k):
        #print(j)
        sum += l[i+j]
        sum3.append(sum)
    #print(sum3)
m = max(sum3)

print((m+k)/2)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
tmp = 0
for p in P[0:K]:
    tmp += p
high = tmp
for i in range(1, N-K+1):
    tmp -= P[i-1]
    tmp += P[i+K-1]
    if tmp > high:
        high = tmp
        e = i
exp = 0
for p in P[e:e+K]:
    exp += sum(range(1,p+1)) / p

print(exp)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
nxt = 0
mx = []
for i in range(n):
    pex = (1+p[i])/2
    mx.append(pex+nxt)
    nxt = pex + nxt
ans = []
for i in range(n-k):
    ans.append(mx[i+k] - mx[i])
print(max(ans))

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
kouho=[]
def saikorokitaiti(A):
    return ((P[A]*(1+P[A])/2)/P[A])
kari=[]
hako=[]
for i in range(N-K+1):
    if i == 0:
        for j in range(K):
            hako.append(saikorokitaiti(i+j))
            if K==1:
                print(sum(hako))
                exit()
    else:
        hako.pop(0)
        hako.append(saikorokitaiti(i+K-1))
        kouho.append(sum(hako))

print(max(kouho))

Submission status: Runtime Error

Solution code:
#D
#　モジュール
import numpy as np
#入力
N,K=map(int,input().split())
P=list(map(int,input().split()))

#処理
#内部関数
def d_1(x):
    t=0
    for i in range(1,x+1):
        t+=i/x
        
    return t

P=np.array([ d_1(i) for i in P])#出る目を期待値に変換
S=np.zeros(K)
for i in range(K):
    S=S+P[i:i+K]
print(np.max(S))

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
ans=[]
for i in range(n-k):
  ans.append(sum(p[i:i+k]))
max_value=max(ans)
max_index=ans.index(max_value)