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: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

e_p = []
for i in range(n):
    e_p.append(0.5*p[i]+0.5)

max = 0
for i in range(n-k+1):
    s=sum(p[i:i+k])
    if s > max:
        max = s
        max_id = i

print(sum(e_p[max_id:max_id+k]))

Submission status: Time Limit Exceeded

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

e_p = []
for i in range(n):
    e_p.append(0.5*p[i]+0.5)

max = 0
for i in range(n-k+1):
    s = sum(e_p[i:i+k])
    if s > max:
        max = s

print(max)

Submission status: Time Limit Exceeded

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

e_p = []
for i in range(n):
    e_p.append(sum(range(1,p[i]+1)) / p[i])

max = 0
for i in range(n-k+1):
    s = sum(e_p[i:i+k])
    if s > max:
        max = s

print(max)

Submission status: Time Limit Exceeded

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

e_p = []
for i in range(n):
    e_p.append(sum(range(1,p[i]+1)) / p[i])

max = 0
for i in range(n-k+1):
    if sum(e_p[i:i+k]) > max:
        max = sum(e_p[i:i+k])

print(max)

Submission status: Time Limit Exceeded

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


for i in range(0, n-k+1):
    k_start = i
    k_end = i + k - 1
    sum_exp = sum(p_exp[k_start: k_end+1])
    ans = max(sum_exp, ans)

print(ans)

Submission status: Time Limit Exceeded

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

ans = -1

for i in range(0, n-k+1):
    k_start = i
    k_end = i + k - 1
    sum_exp = 0
    for dice in range(k_start, k_end+1):
        pi = p[dice]
        sum_exp += (pi + 1)/2
    ans = max(sum_exp, ans)

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
p=list(map(int,input().split()))
array=[]
a_max=0

for n in range(N-(K-1)):
  a = sum(p[n:n+K])
  if a>a_max:
    a_max=a
    

ans=(a_max+K)/2
print(ans)

Submission status: Time Limit Exceeded

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

for n in range(N-(K-1)):
  a = sum(p[n:n+K])
  array.append(a)

ans=(max(array)+K)/2
print(ans)

Submission status: Time Limit Exceeded

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

for n in range(N-(K-1)):
  sum=0
  for k in range(K):
  	sum += p[n+k]
  array.append(sum)

ans=(max(array)+K)/2
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
def kitai(num):
    return (1+float(num))/2 
import numpy as np
l ={}
N,K = map(int,input().split())
#P = list(map(int,input().split()))
P = np.asarray(list(map(kitai,input().split())))
#print(P)

#print(P_)


    

#print(type(P_))


#print(P)
for i in range(0,N-K+1):
    #print(P[i:i+K])
    l[sum(P[i:i+K])]=i
#print(l)
max = max(l.keys())
print(max)

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
sum1=0
max1=0
for i in range(n-k+1):
    sum1=0
    max1=max1
    for j in range(i,i+k):
        sum1=sum1+((1+p[j])/2)
    if sum1>max1:
      max1=sum1
print(max1)

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
sum1=0
max1=0
for i in range(n-k+1):
    sum1=0
    max1=max1
    for j in range(i,i+k):
        sum1=sum1+((1+p[j])/2)
        if sum1>max1:
          max1=sum1
print(max1)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################
import numpy as np
l ={}
N,K = map(int,input().split())
#P = list(map(int,input().split()))
P = np.asarray(list(map(int,input().split())))
#print(P)
P_ = []
#print(P_)

def kitai(num):
    x = 0
    for j in range(num):
        x += num-j
    return x/num
for i in P:
    P_.append(kitai(i))
#print(type(P_))


#print(P)
for i in range(0,N-K+1):
    #print(P[i:i+K])
    l[sum(P_[i:i+K])]=i
#print(l)
max = max(l.keys())
print(max)
import sys
def input():
    return sys.stdin.readline()[:-1]

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################
import numpy as np
l ={}
N,K = map(int,input().split())
#P = list(map(int,input().split()))
P = np.asarray(list(map(int,input().split())))
#print(P)
P_ = []
#print(P_)

def kitai(num):
    x = 0
    for j in range(num):
        x += num-j
    return x/num
for i in P:
    P_ = np.append(P_,kitai(i))
#print(type(P_))


#print(P)
for i in range(0,N-K+1):
    #print(P[i:i+K])
    l[sum(P_[i:i+K])]=i
#print(l)
max = max(l.keys())
print(max)
import sys
def input():
    return sys.stdin.readline()[:-1]

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################
l ={}
N,K = map(int,input().split())
P = list(map(int,input().split()))
P_ = []

def kitai(num):
    x = 0
    for j in range(num):
        x += num-j
    return x/num
for i in P:
    P_.append(kitai(i))
#print(P_)


#print(P)
for i in range(0,N-K+1):
    #print(P[i:i+K])
    l[sum(P_[i:i+K])]=i
#print(l)
max = max(l.keys())
print(max)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
E = list(map(lambda x: (x + 1) * 0.5, list(map(int, input().split()))))
ans = sum(E[:k])
for i in range(1, n - k + 1):
    ans = max(ans, sum(E[i:i + k]))
print(ans)

Submission status: Time Limit Exceeded

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

S = []
for i in range(N):
    S.append(sum(range(p[i]+1))/p[i])

DP = [0 for i in range(N+1)]
SS = sum(S[:K])

for i in range(K):
    DP[i] = SS
# print(DP)
for i in range(K,N):
    DP[i] = DP[i-1]-S[i-K]+S[i]
# print(S)
# print(DP)
print(max(DP))

Submission status: Time Limit Exceeded

Solution code:
N, K = [int(n) for n in input().split()]
#dice = [int(n) for n in input().split()]
evs = [(1 + int(n))/2 for n in input().split()]
maxev = 0
for i in range(N - K + 1):
    current_ev = 0
    for j in range(K):
        current_ev += evs[i + j]
    maxev = max(maxev, current_ev)

print(maxev)

Submission status: Time Limit Exceeded

Solution code:
N, K = [int(n) for n in input().split()]
dice = [int(n) for n in input().split()]

def ev(p):
    return (1 + p)/2

maxev = 0
for i in range(len(dice) - K + 1):
    current_ev = 0
    for j in range(K):
        current_ev += ev(dice[i + j])
    maxev = max(maxev, current_ev)

print(maxev)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
p = list(map(int,input().split()))
maxsum = 0
for i in range(n-k+1):
	cnt = sum(p[i:i+k])
	if cnt >= maxsum:
		maxsum = cnt
print((maxsum+k)/2)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
p = list(map(int,input().split()))
maxsum = 0
for i in range(n-k+1):
	cnt = sum(p[i:i+k])+k
	if cnt >= maxsum:
		maxsum = cnt
print(maxsum/2)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
p = list(map(int,input().split()))
eg = [sum(p[i:i+k])+k for i in range(n-k+1)]
maxsum = 0
for i in range(n-k+1):
	cnt = eg[i]/2
	if cnt >= maxsum:
		maxsum = cnt
print(maxsum)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
p = list(map(int,input().split()))
eg = [(p[i]*(p[i]+1)//2)/p[i] for i in range(n)]
maxsum = 0
for i in range(n-k+1):
	cnt = sum(eg[i:i+k])
	if cnt >= maxsum:
		maxsum = cnt
print(maxsum)

Submission status: Time Limit Exceeded

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

Dices = list(map(lambda n:(n+1)/2,Dices))

# from collections import deque

# d=deque([])
# total= 0
# for i in range(N):
#     d.append((Dices[i]+1)/2)
#     if len(d)==K:
#         total = max(total,sum(d))
#         d.popleft()

# print(total)

#累積和
S=[0]*(N+1)
total = 0

for i in range(N+1):
    S[i] = sum(Dices[:i])

for j in range(N-K+1):
    total = max(total,S[j+K]-S[j])


print(total)

Submission status: Time Limit Exceeded

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

Dices = list(map(lambda n:(n+1)/2,Dices))

# from collections import deque

# d=deque([])
# total= 0
# for i in range(N):
#     d.append((Dices[i]+1)/2)
#     if len(d)==K:
#         total = max(total,sum(d))
#         d.popleft()

# print(total)

#累積和
S=[0]*(N+1)
total = 0
for i in range(N+1):
    S[i] = sum(Dices[:i])

for j in range(N-K+1):
    total = max(total,S[j+K]-S[j])


print(total)

Submission status: Time Limit Exceeded

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

from collections import deque

d=deque([])
total= 0
for i in range(N):
    d.append((Dices[i]+1)/2)
    if len(d)==K:
        total = max(total,sum(d))
        d.popleft()

print(total)

Submission status: Time Limit Exceeded

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

Dices = list(map(lambda n:(n+1)/2,Dices))

from collections import deque

d=deque([])
total= 0
for i in range(N):
    d.append(Dices[i])
    if len(d)==K:
        total = max(total,sum(d))
        d.popleft()

print(total)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N ,K = list(map(int, input().split()))
p = list(map(int, input().split()))
pline=[]
for i in range(N-K+1):
  p[i] = sum(np.array(list(map(lambda x: (x+1)/2, p[i:i+K]))))
  
print(max(p))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N ,K = list(map(int, input().split()))
p = np.array(list(map(int, input().split())))
pline=[]
for i in range(N-K+1):
  num = np.array(list(map(lambda x: (x+1)/2, p[i:i+K])))
  pline.append(num.sum())
print(max(pline))

Submission status: Time Limit Exceeded

Solution code:
N ,K = list(map(int, input().split()))
p = list(map(int, input().split()))
pline=[]
for i in range(N-K+1):
  num = 0
  for j in range(K):
    num+= (p[i+j]+1)/2
  pline.append(num)

print(max(pline))

Submission status: Time Limit Exceeded

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

Dices = list(map(lambda n:(n+1)/2,Dices))

total=0
for i in range(N-K+1):
    j=i+K
    total = max(total,sum(Dices[i:j]))

print(total)

Submission status: Time Limit Exceeded

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

Dices = list(map(lambda n:(n+1)/2,Dices))

totals=[]
for i in range(N-K+1):
    j=i+K
    total = sum(Dices[i:j])
    totals.append(total)

print(max(totals))

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def tsum(l, r):
    return (r + l) * (r - l + 1) // 2

def exp(num):
    return tsum(1, num) / num

def solve():
    n, k = MI()
    P = LI()

    E = [0] * n
    for i in range(n):
        E[i] = exp(P[i])
    # print(E)

    _max = -1
    for i in range(n-k+1):
        e = E[i:i+k]
        _sum = sum(e)
        # print(e, _sum, i)
        if _max < _sum:
            _max = _sum

    print(_max)

if __name__ == '__main__':
    solve()

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def exp(num):
    return sum(range(1, num+1)) / num

def solve():
    n, k = MI()
    P = LI()

    E = [0] * n
    for i in range(n):
        E[i] = exp(P[i])
    # print(E)

    _max = -1
    for i in range(n-k+1):
        e = E[i:i+k]
        _sum = sum(e)
        # print(e, _sum, i)
        if _max < _sum:
            _max = _sum

    print(_max)

if __name__ == '__main__':
    solve()

Submission status: Time Limit Exceeded

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

exp = [(1+i)/2 for i in p]

t = []
for i in range(len(p)-k+1):
    t.append(sum(p[i:i+k]))
ind = t.index(max(t))

max_pair = exp[ind:ind+k]

print(sum(max_pair))

Submission status: Time Limit Exceeded

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

t = []
for i in range(len(p)-k+1):
    t.append(sum(p[i:i+k]))
ind = t.index(max(t))

max_pair = p[ind:ind+k]
exp = []
for i in max_pair:
    sums=0
    for j in range(1,i+1):
        sums += j/i
    exp.append(sums)
print(sum(exp))

Submission status: Time Limit Exceeded

Solution code:
#import math

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

if (k == 1):
    maxP = max(p)
    ans = (maxP + 1) / 2.0

elif (n == k):
    tt = sum(p) + n
    ans = tt / 2.0

else:
    val = [0] * (n - k + 1)
    for i in range(n - k + 1):
        list1 = p[i:i + k]

        val[i] = sum(list1)
 #   print(val)
    maxVal = max(val)
    ans = (maxVal + k) / 2.0

print(ans)

Submission status: Time Limit Exceeded

Solution code:
#import math

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

e = [0] * n
for i in range(n):
    tar = p[i]
    if (tar == 1):
        e[i] = 1
    else:
        e[i] = (tar+1)/2.0
if (k == 1):
    ans = max(e)
else:
    val = [0] * (n - k + 1)
    for i in range(n - k + 1):
        list1 = e[i:i + k]

        val[i] = sum(list1)
 #   print(val)
    ans = max(val)

print(ans)

Submission status: Time Limit Exceeded

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

p = [sum(p[0+i:k+i]) for i in range(n-k+1)]
print((max(p)+k)/2)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
p_ls = list(map(int, input().split()))
e_ls = [0] * n
for i in range(n):
    p = p_ls[i]
    e = (p*(1+p) // 2) / p
    e_ls[i] = e
max_exp = 0
for start in range(n):
    sum_exp = sum(e_ls[start:start+k])
    max_exp = max(max_exp, sum_exp)
print(max_exp)

Submission status: Time Limit Exceeded

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


def ave(num):
    return (1 + num) / 2


ave_list = []
max_sum = 0
Kdaice_list = []
for i in range(N - K + 1):
    K_sum = sum(p_list[i:i + K])
    if max_sum < K_sum:
        max_sum = K_sum
        Kdaice_list = []
        max_ave = 0
        for d in p_list[i:i + K]:
            max_ave += ave(d)
        ave_list.append(max_ave)

print(max(ave_list))

Submission status: Time Limit Exceeded

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

max_sum = 0
Kdaice_list = []
for i in range(N - K + 1):
    K_sum = sum(p_list[i:i + K])
    if max_sum < K_sum:
        max_sum = K_sum
        Kdaice_list = []
        for d in p_list[i:i + K]:
            Kdaice_list.append(d)


def ave(num):
    sum_num = 0
    for n1 in range(1, num + 1):
        sum_num += n1
    return sum_num / num


ans = 0
for n in Kdaice_list:
    ans += ave(n)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
p = list(map(int, input().split()))
e = []
b = [sum(range(pi+1)) for pi in p]
for i in range(N-K+1):
    E = 0
    for k in range(K):
        E += b[i+k]/p[i+k]
    e.append(E)
print(max(e))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
p = list(map(int, input().split()))
e = []
for i in range(N-K+1):
    E = 0
    for k in range(K):
        E += sum(range(1, p[i+k]+1))/p[i+k]
    e.append(E)
print(max(e))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
p = list(map(int, input().split()))
e = []
for i in range(N-K+1):
    E = 0
    for j in range(i, i+K):
        E += sum(range(1, p[j]+1))/p[j]
    e.append(E)
print(max(e))

Submission status: Time Limit Exceeded

Solution code:
problem_info = input().split()
dice_num = int(problem_info[0])
option_num = int(problem_info[1])

prob_list = [(1+int(i))/2 for i in input().split()]
max = -1

for i in range(len(prob_list) - option_num + 1):
  prob_sum = 0
  prob_sum = sum(prob_list[:(i+option_num)]) - sum(prob_list[:i])
  if max < prob_sum:
    max = prob_sum

print(max)

Submission status: Time Limit Exceeded

Solution code:
def cal_expectation(list,index,option):
  expect = 0
  for i in range(index,index+option):
    expect += list[i]*(list[i]+1)/(2*list[i])
  return expect

problem_info = input().split()
dice_num = int(problem_info[0])
option_num = int(problem_info[1])

prob_list = [int(i) for i in input().split()]
max = -1
max_index = 0

for i in range(len(prob_list) -option_num + 1):
  sum_prob = 0
  for j in range(i,i+option_num):
    sum_prob += prob_list[j]
  if max < sum_prob:
    max = sum_prob
    max_index = i

print(cal_expectation(prob_list,max_index,option_num))

Submission status: Time Limit Exceeded

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

mx=0
for i in range(N-K+1):
  mx=max(mx,sum(p[i:i+K]))
print((mx+K)/2)

Submission status: Time Limit Exceeded

Solution code:
N,K=[int(x) for x in input().rstrip().split()]
p=[int(x) for x in input().rstrip().split()]
ex=[1/2*(i+1) for i in p]

mx=0
ind=0
ans=0
# for i in range(ind,ind+K):
#   ans+=ex[p[i]-1]
s=0
for i in range(N-K+1):
  s=sum(ex[i:i+K])
  mx=max(mx,s)
print(mx)

Submission status: Time Limit Exceeded

Solution code:
N,K=[int(x) for x in input().rstrip().split()]
p=[int(x) for x in input().rstrip().split()]
ex=[1/2*(i+1) for i in p]

mx=0
ind=0
ans=0
# for i in range(ind,ind+K):
#   ans+=ex[p[i]-1]

for i in range(N-K+1):
  mx=max(mx,sum(ex[i:i+K]))
print(mx)

Submission status: Time Limit Exceeded

Solution code:
N,K=[int(x) for x in input().rstrip().split()]
p=[int(x) for x in input().rstrip().split()]
ex=[1/2*(i+1) for i in range(1,1001)]

mx=0
ind=0
for i in range(N-K+1):
  if mx<max(mx,sum(p[i:i+K])):
    ind=i
    mx=max(mx,sum(p[i:i+K]))



ans=0
# for i in range(ind,ind+K):
#   ans+=ex[p[i]-1]
i=ind
while(K):
  ans+=ex[p[i]-1]
  i+=1
  K-=1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,K=[int(x) for x in input().rstrip().split()]
p=[int(x) for x in input().rstrip().split()]
ex=[1/2*(i+1) for i in range(1,1001)]

p_x=[0 for i in range(N)]

mx=0
ind=0
for i in range(N-K+1):
  if mx<max(mx,sum(p[i:i+K])):
    ind=i
    mx=max(mx,sum(p[i:i+K]))

# print(ind,mx)
ans=0
for i in range(ind,ind+K):
  ans+=ex[p[i]-1]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
p = list(map(int, input().split()))
q = [sum(range(i+1)) for i in p]
Exp = []
for i in range(N-K+1):
    x = 0
    for j in range(i, i+K):
        x += q[j]/p[j]
    Exp.append(x)
print(max(Exp))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
p = list(map(int, input().split()))
Exp = [0]*(N-K+1)
for i in range(N-K+1):
    x = 0
    for j in range(i, i+K):
        x += (sum(range(1, p[j]+1)))/p[j]
    Exp[i] = x
print(max(Exp))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
p = list(map(int, input().split()))
Exp = []
for i in range(N-K+1):
    x = 0
    for j in range(i, i+K):
        x += (sum(range(1, p[j]+1)))/p[j]
    Exp.append(x)
print(max(Exp))

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
aklist = []
for i in range(n - k + 1):
  aklist.append(p[i:i + k])
dnum = []
for m in aklist:
  ksum = (sum(m) + len(m)) / 2.0
  dnum.append(ksum)
print(max(dnum))

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
aklist = []
for i in range(n - k + 1):
  klist = []
  for j in range(k):
    klist.append(p[i + j])
  aklist.append(klist)
dnum = []
for m in aklist:
  ksum = 0
  for l in m:
    ksum += (l + 1) / 2.0
  dnum.append(ksum)
print(max(dnum))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
max_value = 0
ans_p = 0
for i in range(n):
    sum_ = sum(p[i:i+k])
    if (sum_ > max_value):
        max_value = sum_
        ans_p = p[i:i+k]
print((max_value+k)/2)

Submission status: Time Limit Exceeded

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

if __name__ == '__main__':
    solve()

Submission status: Time Limit Exceeded

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

def expected(sm, k):
    return (sm+k)/2

max=0

for i in range(n-k+1):
    slc=p[i:(i+k)]
    sm=sum(slc)
    if max <= sm:
        max=sm

print(expected(max, k))

Submission status: Time Limit Exceeded

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

res = 0
flag = 0
ans = 0

for i in range(n):
    if res < sum(p[i:i+k]):
        res = sum(p[i:i+k])
        flag = i
        
for i in range(k):
    if p[flag+i]%2 == 0:
        ans += (p[flag+i]/2) + 0.5
    else:
        ans += (p[flag+i] + 1)/2
        
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int, input().split())
P = list(map(int, input().split()))
P_max = 0
for i in range(len(P)):
    P_new = P[i:i+K]
    P_sum = sum(P_new)
    if P_sum > P_max:
        P_max = P_sum
print(P_max/2+0.5*K)

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int, input().split())
P = list(map(int, input().split()))
Ex = {}
for i in range(1,1001):
    Ex[i] = sum([x*1/i for x in range(1, i+1)])

P_ex = []
for t in P:
    P_ex.append(Ex[t])

Sum = []
for l in range(len(P_ex)):
    Sum.append(sum(P_ex[l:l+K]))

print(max(Sum))

Submission status: Time Limit Exceeded

Solution code:

def myAnswer(N:int,K:int,P:list) ->  int:
   ans =[]
   for p in P:
      tmp =(p+1)/2
      ans.append(tmp)
   accum = []
   for i in range(0,N-K+1,1):
      accum.append(sum(ans[i:i+K]))
   # print(accum)
   return max(accum)

def modelAnswer():
   return
def main():
   N,K = map(int,input().split())
   P = list(map(int,input().split()))
   print(myAnswer(N,K,P[:]))
if __name__ == '__main__':
   main()

Submission status: Time Limit Exceeded

Solution code:
def myAnswer(N:int,K:int,P:list) ->  int:
   l =[]
   for i in range(0,N-K+1,1):
      l.append(sum(P[i:i+K]))
   target = l.index(max(l))
   ans = 0
   for t in range(target,target+K):
      p = P[t]
      ans += ((p * (p + 1)) // 2) / p

   return ans

def modelAnswer():
   return
def main():
   N,K = map(int,input().split())
   P = list(map(int,input().split()))
   print(myAnswer(N,K,P[:]))
if __name__ == '__main__':
   main()

Submission status: Time Limit Exceeded

Solution code:
def myAnswer(N:int,K:int,P:list) ->  int:
   l =[]
   for i in range(0,N-K+1,1):
      l.append(sum(P[i:i+K]))
   target = l.index(max(l))
   ans = 0
   for t in range(target,target+K):
      total = 0
      for i in range(1,P[t]+1):
         total += i
      ans += total/P[t]

   return ans

def modelAnswer():
   return
def main():
   N,K = map(int,input().split())
   P = list(map(int,input().split()))
   print(myAnswer(N,K,P[:]))
if __name__ == '__main__':
   main()

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
m = mi = 0
for i in range(n):
    s = sum(p[i:i+k])
    if m < s:
        m = s
        mi = i
ans = 0
for i in range(mi, mi + k):
    x = p[i] * (p[i] + 1) // 2
    ans += x / p[i]
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
p_list = list(map(int,input().split()))
ans = 0
save = 0
sum = 0
for i in range(n-k+1):
    dum = 0
    for j in range(k):
        dum += p_list[i+j]
    if dum > ans:
        save = i
        ans = dum
for i in range(save,save+k):
    sum += p_list[i]*0.5 + 0.5
print(sum)

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int, input().split())
P = list(map(int,input().split()))
Px  =[]
temp_max = 0
for i in range(N):
    Px.append((1+P[i])/2)
for j in range(N-K+1):
    temp_num = sum(Px[j:j+K])
    if temp_max <temp_num:
        temp_max=temp_num
print(temp_max)

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int, input().split())
P = list(map(int,input().split()))
Px  =[0]*N
temp_max = 0
for i in range(N):
    Px[i] = (1+P[i])/2
for j in range(N-K+1):
    temp_num = sum(Px[j:j+K])
    if temp_max <temp_num:
        temp_max=temp_num
print(temp_max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int, input().split())
P = list(map(int,input().split()))
Px  =[0]*N
Pxx = []
for i in range(N):
    Px[i] = (1+P[i])/2
for j in range(N-K+1):
    temp_num = sum(Px[j:j+K])
    Pxx.append(temp_num)
print(max(Pxx))

Submission status: Time Limit Exceeded

Solution code:
l = [int(x) for x in input().split()]
N = l[0]
K = l[1]
P = [int(x) for x in input().split()]

expected = []
a = 0
ans = []

for i in range(len(P)):
    expected.append((P[i]+1)/2)
#print(expected)

for k in range(N - K + 1):
    a = 0
    for x in range(K):
        a += expected[k+x]
    ans.append(a)
#print(ans)
print(max(ans))

Submission status: Time Limit Exceeded

Solution code:
l = [int(x) for x in input().split()]
N = l[0]
K = l[1]
P = [int(x) for x in input().split()]

expected = []
a = 0
ans = []

for i in range(len(P)):
    a = 0
    for j in range(P[i]):
        a += ((j+1)/P[i])
    expected.append(a)
#print(expected)

for k in range(N - K + 1):
    a = 0
    for x in range(K):
        a += expected[k+x]
    ans.append(a)
#print(ans)
print(max(ans))

Submission status: Time Limit Exceeded

Solution code:
num,renzoku=map(int,input().split())
dices=list(map(int,input().split()))
max_renzoku=[]
for i in range(0,num-renzoku+1):
  max_renzoku.append(sum(dices[i:i+renzoku]))
print((max(max_renzoku)+renzoku)/2)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
l = list(map(int, input().split()))
l = list(map(lambda x: (((x + 1) * x) / 2) / x, l))
l_2 = []
for i in range(len(l) - (k - 1)):
    l_2 += [sum(l[i:i + k])]
print(max(l_2))

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
E=lambda x:(x+1)/2
p=list(map(int,input().split()))
P=[E(n) for n in p]

M=0
for i in range(N-K+1):
    m=sum(P[i:i+K])
    M=max(M,m)
print(M)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
x, y = map(int,input().split())
p = list(map(int,input().split()))
ans = 0

for i in range(x-y+1):
    z = (sum(p[i:i+y])+y)/2
    if z > ans:
        ans = z

print(ans)