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 = [int(x) for x in input().split()]
ps = [int(x) for x in input().split()]

exp = [(pi+1) / 2 for pi in ps]
sum_exp = [sum(exp[i:i+K]) for i in range(N-K+1)]

print(max(sum_exp))

Submission status: Time Limit Exceeded

Solution code:
def kitai(n):
  return (int(n)+1)/2

import numpy as np
N,K=map(int,input().split())

L=np.array([list(map(kitai, input().split()))]).reshape(-1)
M=0
M_IND=0

for i in range(len(L)-(K-1)):
  tmp = sum(L[i:i+K])
  #print(tmp)
  if M < tmp:
    M = tmp

print(M)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys

def solve(N: int, K: int, p: "List[int]"):
    ans = 0.0
    ps = []
    for i in range(0,N-K+1):
        tmp = 0
        for j in range(i,i+K):
            tmp += p[j]

        ps.append(tmp)
    ans = (max(ps)/2) + (K * 0.5)
    print(ans)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, p)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N,K=map(int,input().split())
L=np.array([list(map(int, input().split()))]).reshape(-1)
M=0
M_IND=0

for i in range(len(L)-(K-1)):
  tmp = sum(L[i:i+K])
  #print(tmp)
  if M < tmp:
    M = tmp
    M_IND=i
#print(M_IND)
#for k in range(L[M_IND,M_IND+K])
ANS=0
MEMO=[0]*(max(L[M_IND:M_IND+K])+1)
MEMO_MIN=0
for i in L[M_IND:M_IND+K]:
  #print(i)
  ex = 0
  if MEMO[i] == 0:
    ex= (i+1)/2
    MEMO[i] = ex
  else:
    ex = MEMO[i]
  ANS += ex
print(ANS)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N,K=map(int,input().split())
L=np.array([list(map(int, input().split()))]).reshape(-1)
M=0
M_IND=0

for i in range(len(L)-(K-1)):
  tmp = sum(L[i:i+K])
  #print(tmp)
  if M < tmp:
    M = tmp
    M_IND=i
#print(M_IND)
#for k in range(L[M_IND,M_IND+K])
ANS=0
MEMO=[0]*(max(L[M_IND:M_IND+K])+1)
MEMO_MIN=0
for i in L[M_IND:M_IND+K]:
  #print(i)
  ex = 0
  p = 1/i
  if MEMO[i] == 0:
    for x in range(i+1):
        px = p*x
        ex += px
    MEMO[i] = ex
  else:
    ex = MEMO[i]
  ANS += ex
print(ANS)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
L=[]
def E(n):
  e=0
  for i in range(1,n+1):
    e+=i
  e = e/n
  return e

k=0
for i in range(N-K+1):
  l=sum(P[i:i+K])
  if l>k:
    k=l
    L=P[i:i+K]

A=0
for i in range(K):
  A+=E(L[i])
print(A)

Submission status: Time Limit Exceeded

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

p = [((1+int(i))*int(i)/2)/int(i) for i in input().split()]

res = 0
for j in range(N-K+1):
  ans = 0
  for i in range(K):
    ans += p[j+i]
  res = max(res,ans)
  
print(res)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

ans = 0
arr = np.zeros(n-k+1)

for i in range(k):
    arr += np.array(p[i:n-k+i+1]) / 2

arr += k / 2

print(np.max(arr))

Submission status: Time Limit Exceeded

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

p = [((1+int(i))*int(i)/2)/int(i) for i in input().split()]

res = 0
for j in range(N-K+1):
  ans = sum([x for x in p[j:j+K]])
  res = max(res,ans)
  
print(res)

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np

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

p = np.array([list(map(int, input().split()))]).reshape(-1)

sum_max = 0
index_max = -1
for i in range(n-k+1):
    mx = np.sum(p[i:i+k])
    if mx > sum_max:
        sum_max = mx
        index_max = i
print(str((sum_max+k) / 2))

Submission status: Time Limit Exceeded

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

p = [((1+int(i))*int(i)/2)/int(i) for i in input().split()]


res = 0
for j in range(N-K+1):
  res = max(res,sum(p[j:j+K]))
  
print(res)

Submission status: Time Limit Exceeded

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

p = [int(x) for x in input().split()]

res = 0
for j in range(N-K+1):
  q = p[j:j+K]
  ans = 0
  for i in q:
    ans += ((1+i)*i/2)/i
  res = max(res,ans)
  
print(res)

Submission status: Time Limit Exceeded

Solution code:
from collections import deque

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

q = deque()
s = 0

for i, j in enumerate(p):
    q.append((j+1)/2)
    if i == k-1:
        s = sum(q)
    elif i > k-1:
        q.popleft()
        s = max(s, sum(q))
print(s)

Submission status: Time Limit Exceeded

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

X = [sum([i for i in range(1, p[i]+1)])/p[i] for i in range(n)]

x_sum = []
for i in range(len(X)):
    tmp = X[i:i+k]
    if k != len(tmp):
        break
    else:
        x_sum.append(sum(tmp))

print(sorted(x_sum)[-1])

Submission status: Time Limit Exceeded

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

ans = 0

for i in range(n-k+1):
    tmp = sum(p[i:i+k]) / 2 + k / 2
    if ans < tmp:
        ans = tmp

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

a1 = input()
a2 = input()

list1 = np.array(list(map(int,a1.split(" "))))
list2 = (np.array(list(map(int,a2.split(" "))))+1)/2

res = 0
for i in range(0,len(list2)-list1[1]+1):
    res = max(res,sum(list2[i:i+list1[1]]))
print(res)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

N,K = input().split()
pl = input().split()
pk = []
for p in pl:
    i = 0
    j = 0
    kitaiti = 0
    kari = 0
    for i in range(1,int(p)+1):
        j += i
    pk.append(j/int(p))
for z in range(len(pk)+1):
    if int(K) <= len(pk)-z:
        kari = 0
        for x in range(int(z),(int(z)+int(K))):
            kari += pk[int(x)]
    if kitaiti < kari:
        kitaiti = kari
print(kitaiti)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

N,K = input().split()
pl = input().split()
pk = []
for p in pl:
    i = 0
    j = 0
    kitaiti = 0
    kari = 0
    for i in range(1,int(p)+1):
        j += i
    pk.append(j/int(p))
for z in range(len(pk)+1):
    if int(K) <= len(pk)-z:
        kari = 0
        maxrange = int(z)+int(K)
        for x in range(int(z),maxrange):
            kari += pk[int(x)]
    if kitaiti < kari:
        kitaiti = kari
print(kitaiti)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

N,K = input().split()
pl = input().split()

pk = []

if 1 <= int(K) and int(K) <= int(N) and int(N) <= 200000 and len(pl) == int(N):
    for p in pl:
        i = 0
        j = 0
        kitaiti = 0
        kari = 0
        for i in range(1,int(p)+1):
            j += i
        pk.append(j/int(p))
    for z in range(len(pk)+1):
        if int(K) <= len(pk)-z:
            kari = 0
            maxrange = int(z)+int(K)
            for x in range(int(z),maxrange):
                kari += pk[int(x)]
        if kitaiti < kari:
            kitaiti = kari
print(kitaiti)

Submission status: Time Limit Exceeded

Solution code:
N,K = input().split()
pl = input().split()

pk = []

if 1 <= int(K) and int(K) <= int(N) and int(N) <= 200000 and len(pl) == int(N):
    for p in pl:
        i = 0
        j = 0
        kitaiti = 0
        kari = 0
        for i in range(1,int(p)+1):
            j += i
        pk.append(j/int(p))
    for z in range(len(pk)+1):
        jougen = len(pk)-z
        if int(K) <= jougen:
            kari = 0
            maxrange = int(z)+int(K)
            for x in range(int(z),maxrange):
                kari += pk[int(x)]
        if kitaiti < kari:
            kitaiti = kari
print(kitaiti)

Submission status: Time Limit Exceeded

Solution code:
def f(i):
    return (i + 1) / 2


n, k = [int(i) for i in input().split()]
p = [f(int(i)) for i in input().split()]
ans = sum(p[0:k])
for i in range(1, n - 2):
    ans = max(ans, sum(p[i : i + k]))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def f(i):
    return sum(range(1, i + 1)) / i


n, k = [int(i) for i in input().split()]
p = [f(int(i)) for i in input().split()]
ans = sum(p[0:k])
for i in range(1, n - 2):
    ans = max(ans, sum(p[i : i + k]))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import copy

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

def max_sum_section(arr, k):
    sec = []
    for i in range(k):
        sec.append(arr[i])
    max_sec = copy.deepcopy(sec)
    # TODO: i から i+k-1 までの区間和が最大である区間を求めよ
    for i in range(k, len(arr)):
        sec.pop(0)
        sec.append(arr[i])
        if sum(sec) > sum(max_sec):
            max_sec = copy.deepcopy(sec)
    return max_sec

def e_dice(n):
    res = 0
    for i in range(1, n+1):
        res += i * (1 / n)
    return res

res = 0
sec = max_sum_section(p, K)
for i in range(K):
    res += e_dice(sec[i])

print(res)

Submission status: Time Limit Exceeded

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

P_ = []

for i in p:
    P_.append((1+i)/2)

ma = 0

for i in range(N-K+1):
    if ma < sum(P_[i:i+K]):
        ma = sum(P_[i:i+K])

print(ma)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
P = list(map(int,input().split()))
sum_a = 0
index = 0

for i in range(k):
    sum_a += P[i]
num = sum_a
for j in range(1,n-k+1):
    num += P[j+k-1]
    #print(num)
    num -= P[j-1]
    #print(num)
    if(sum_a<num):
        index = j
        sum_a = num

total = 0.0
for m in range(index,index+k):
    total += sum(list(range(P[m]+1)))/P[m]
print(total)

Submission status: Time Limit Exceeded

Solution code:
total, tar = list(map(int, input().split()))
dice_array = list(map(int, input().split()))

tar2 = 0
calc_before = 0
calc_now = 0
for i in range(total+1-tar):
  calc_now = sum(dice_array[i:i+tar])
  if calc_before < calc_now:
    tar2 = i
    calc_before = calc_now
  calc_now = 0

sum_data = 0
cnt = 0
for i in range(tar2, tar+tar2):
  cnt = sum(list(range(1, dice_array[i] + 1)))
  sum_data += (cnt / dice_array[i])
  
print(sum_data)

Submission status: Time Limit Exceeded

Solution code:
total, tar = list(map(int, input().split()))
dice_array = list(map(int, input().split()))
l = [] * total

tar2 = 0
calc_before = 0
calc_now = 0
for i in range(total+1-tar):
  calc_now = sum(dice_array[i:i+tar])
  if calc_before < calc_now:
    tar2 = i
    calc_before = calc_now
  calc_now = 0

sum_data = 0
cnt = 0
for i in range(tar2, tar+tar2):
  cnt = sum(list(range(1, dice_array[i] + 1)))
  sum_data += (cnt / dice_array[i])
  
print(sum_data)

Submission status: Time Limit Exceeded

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

def calc_expected_val(val):
    return (K+val)/2

def main():
    sum_K_list = []
    max_sum_K = 0
    max_expected_val = 0
    for i in range(N-K+1):
        sum_K = 0   
        for j in range(i, i+K):
            sum_K += P[j]
        sum_K_list.append(sum_K)

    max_sum_K = max(sum_K_list)
    max_expected_val = calc_expected_val(max_sum_K)    
    print(max_expected_val)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
total, tar = list(map(int, input().split()))
dice_array = list(map(int, input().split()))
l = [] * total

tar2 = 0
calc_before = 0
calc_now = 0
for i in range(total+1-tar):
  calc_now = sum(dice_array[i:i+tar])
  if calc_before < calc_now:
    tar2 = i
    calc_before = calc_now
  calc_now = 0

sum = 0
for i in range(tar2, tar+tar2):
  cnt = 0
  for j in range(1, dice_array[i]+1):
    cnt += j
  sum += (cnt / dice_array[i])
  
print(sum)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
p = list(map(int,input().split()))
ans = []
volatility = 0
a = 0

for i in range(len(p)):
    ex = (1 + p[i])/2
    p[i] = ex
    
for i in range(K, N+1):
    for j in range(i-K, i):
        volatility += p[j]
    
    ans.append(volatility)
    volatility = 0

a = max(ans)
print(a)

Submission status: Time Limit Exceeded

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

#print(sum(p[1:4]))
maxid = 0
for i in range(N - (K-1)):
    if(sum(p[maxid:(maxid+K)]) < sum(p[i:(i+K)])):
        maxid = i

maxsum = 0
for i in range(K):
    maxsum += ((p[maxid+i]*(p[maxid+i]+1))/2)/p[maxid+i]

print(maxsum)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3

import sys
import os

def expectation(ps):
    return sum((p + 1) * 0.5 for p in ps)

def solve(n, k, ps):
    imax = 0
    isum = 0

    for i in range(0, n - k + 1):
        s = sum(ps[i:i+k])
        if s > isum:
            imax = i
            isum = s

    return expectation(ps[imax:imax+k])

def read_ints(n, line):
    ns = []
    i = 0
    for c in range(0, n):
        iend = line.find(" ", i)
        if iend < 0:
            iend = len(line)
        ns.append(int(line[i:iend]))
        i = iend + 1

    return ns

def main():
    n, k = [int(x) for x in sys.stdin.readline().split()]
    ps = read_ints(n, sys.stdin.readline().strip())

    ans = solve(n, k, ps)

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def summ(num):
    s = 0
    for i in range(num):
        i+=1
        s+=i
    return s
n, k = map(int, input().split(" "))
l = list(map(int, input().split(" ")))
t = n-k+1
a = 0
for i in range(t):
    r = 0
    for c in range(k):
        g = summ(l[i+c])
        r += g/l[i+c]
    if r > a:
        a = r
print(a)

Submission status: Time Limit Exceeded

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

x = 0
y = 0
for i in range(n-k+1):
    a = sum(l[i:i+k])
    if x < a:
        x = a
        y = i
#print(x,y)

z = 0
#for j in range(y,y+k):
#    z += (l[j]+1)/2

print((sum(l[y:y+k]) + k)/2)

Submission status: Time Limit Exceeded

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

x = 0
y = 0
for i in range(n-k+1):
    if x < sum(l[i:i+k]):
        x = sum(l[i:i+k])
        y = i
#print(x,y)

z = 0
#for j in range(y,y+k):
#    z += (l[j]+1)/2

print((sum(l[y:y+k]) + k)/2)

Submission status: Time Limit Exceeded

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

max = 0
for i in range(n-k+1):
  if i == 0:
    s = sum(ps[i:i+k])
  else:
    s = s - (ps[i-1] - ps[i+k-1])
  s = sum(ps[i:i+k])
  if s > max:
    max = s
print((max + k) / 2)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
p_mean = [(1+pi)/2 for pi in p]
p_mean_sum_max = max([sum(p_mean[i:i+K]) for i in range(len(p_mean)-K+1)])
print(p_mean_sum_max)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())#サイコロの個数、「隣接した」サイコロを振る数
p = list(map(float,input().split()))#さいころの目の最大値
judge = []
ans = 0
for i in range(n-k+1):
    expect = 0
    expect = (sum(p[i:i+k]) + k)/2
    ans =max(ans,expect)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())#サイコロの個数、「隣接した」サイコロを振る数
p = list(map(float,input().split()))#さいころの目の最大値
judge = []
ans = 0
for i in range(n-k+1):
    expect = 0
    expect = (sum(p[i:i+k]) + k)/2
    if ans < expect:
        ans = expect
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())#サイコロの個数、「隣接した」サイコロを振る数
p = list(map(float,input().split()))#さいころの目の最大値
judge = []
for i in range(n-k+1):
    expect = 0
    for j in range(k):
        expect += (p[i+j] + 1)/2
    judge.append(expect)
print(max(judge))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
c = list(map(int, input().split()))
d = [(i + 1) / 2 for i in c]
e = sum(d[:b])
for i in range(a - b + 1):
	f = sum(d[i:b + i])
	if f > e:
		e = f
print(e)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
c = list(map(int, input().split()))
d = [(i + 1) / 2 for i in c]
e = [sum(d[i:b + i]) for i in range(a - b + 1)]
print(max(e))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
c = list(map(int, input().split()))
d = [(c[i] + 1)/ 2 for i in range(a)]
e = [sum(d[i:b + i]) for i in range(a - b + 1)]
g = max(e)
print(g)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
c = list(map(int, input().split()))
d = [(sum(range(1, c[i] + 1)) / c[i]) for i in range(a)]
e = [sum(d[i:b + i]) for i in range(a - b + 1)]
print(max(e))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
c = list(map(int, input().split()))
d = [sum(c[i:b + i]) for i in range(a - b + 1)]
e = 0
g = d.index(max(d))
for i in range(b):
	e += sum(range(1, c[g + i] + 1)) / c[g + i]
print(e)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
c = list(map(int, input().split()))
d = [sum(c[i:b + i]) for i in range(a - b + 1)]
e = 0
g = d.index(max(d))
for i in range(b):
	f = sum(range(1, c[g + i] + 1))
	e += f / c[g + i]
print(e)

Submission status: Time Limit Exceeded

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

sum_list = []
sum_tmp = 0

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

	for t in range(i, i+k):
		tmp += p_list[t]

	if sum_tmp < tmp:
		sum_tmp = tmp

print((sum_tmp+k)/2)

Submission status: Time Limit Exceeded

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

sum_list = []
sum_tmp = 0

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

	for t in range(i, i+k):
		tmp += p_list[t]

	sum_list.append([tmp, i])

sum_list.sort(reverse = True)

#print(sum_list[0])

for s in range(sum_list[0][1], sum_list[0][1]+k):
	sum_tmp += (p_list[s]+1)/2

print(sum_tmp)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
n, k = map(int,input().split())
p = [int(i) for i in input().split()]

kitai = []
for i in range(n):
    kitai.append((1 + p[i]) / 2)

ans = 0
for i in range(n - k + 1):
    tmp2 = 0
    for j in range(i, i + k):
        tmp2 += kitai[j]
    if ans < tmp2:
        ans = tmp2
print(ans)

Submission status: Time Limit Exceeded

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

    for i in range(N-K+1):
        max_total = max(max_total, sum(P[i:i+K]))

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


if __name__ == '__main__':
    solve()

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
P = list(map(int, input().split()))
max_total = 0

for i in range(N-K+1):
    max_total = max(max_total, sum(P[i:i+K]))

ans = (max_total + K) / 2

print(ans)

Submission status: Time Limit Exceeded

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

for i in range(n-(k-1)):
  expect = (sum(p[i:i+k])+k)/2
  if expect > current_best:
    current_best = expect
print(current_best)

Submission status: Time Limit Exceeded

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

p_kitai = []
max = 0
max2 = 0

for i in range(len(p)):
    p_kitai.append(sum(range(1,p[i]+1))/p[i])
    
for i in range(len(p)-K+1):
    k = i
    for j in range(K):
        max += p_kitai[k]
        k += 1
    if max > max2:
        max2 = max
        max = 0
    else:
        max = 0
        
print(max2)

Submission status: Time Limit Exceeded

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

for i in range(N-K+1):
    max_total = max(max_total, sum(P[i:i+K]))

ans = (max_total + K) / 2

print(ans)

Submission status: Time Limit Exceeded

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

E = 0
max = 0
for i in range(N - K + 1):
    work = sum(P_E[i:i+K])
    if work > max:
        max = work

print(max)

Submission status: Time Limit Exceeded

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

E = 0
max = 0
for i in range(N - K + 1):
    work = sum(P[i:i+K])
    if work > max:
        max = work
        max_values = P[i:i+K]

for m in max_values:
    E += (1 + m) * (1/2)

print(E)

Submission status: Time Limit Exceeded

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

for i in range(N-K+1):
    total = sum(P[i:i+K])
    if total > max_total:
        max_total = total
        ans = sum(map(lambda x: (x + 1) / 2, P[i:i+K]))

print(ans)

Submission status: Time Limit Exceeded

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

E = 0
max = 0
for i in range(N - K + 1):
    work = sum(P[i:i+K])
    if work > max:
        max = work
        max_values = P[i:i+K]

for m in max_values:
    E += (1 + m) * m * (1/2) * (1/m)

print(E)

Submission status: Time Limit Exceeded

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

p_list= list(map(int, input().split()))

#p_list = [(p+1)/2 for p in p_list]
max_sump = 0
for i in range(n-k+1):
    sump_candidate = sum(p_list[i:i+k]) 
    max_sump = sump_candidate if sump_candidate >= max_sump else max_sump
max_sump = (max_sump + k)/2
print(max_sump)

Submission status: Time Limit Exceeded

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

p_list= list(map(int, input().split()))

p_list = [(p+1)/2 for p in p_list]
max_sump = 0
for i in range(n-k+1):
    sump_candidate = sum(p_list[i:i+k]) 
    max_sump = sump_candidate if sump_candidate >= max_sump else max_sump
print(max_sump)

Submission status: Time Limit Exceeded

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

for i in range(N-K+1):
    expected = sum(map(lambda x: (x + 1) / 2, P[i:i+K]))
    ans = max(ans, expected)

print(ans)

Submission status: Time Limit Exceeded

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

E = 0
max = 0
for i in range(N - K + 1):
    work = sum(P[i:i+K])
    if work > max:
        max = work
        max_values = P[i:i+K]

for m in max_values:
    E += (1 + m) * m * (1/2) * (1/m)

print(E)

Submission status: Time Limit Exceeded

Solution code:
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys

# import itertools
# import math
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K, *P = map(int, read().split())

ans = 0
for i in range(N - K + 1):
    L = P[i:i + K]
    s = (sum(L) + K) / 2
    ans = max(s, ans)
print('{:.10f}'.format(ans))

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
P = map(int, input().split())
avg = list(map(lambda x: (x + 1) / 2, P))
ans = 0

for i in range(N-K+1):
    ans = max(ans, sum(avg[i:i+K]))

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
P = list(map(int, input().split()))
E = []
for i in range(N-K+1):
    temp = (K + sum(P[i:i+K])) / 2
    E.append(temp)
print(max(E))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
c = list(map(int, input().split()))
d = []
h = 0
for i in range(a - b + 1):
	h = sum(c[i:b + i])
	d.append(h)
e = 0
f = 0
g = d.index(max(d))
for i in range(b):
	f = sum(range(1, c[g + i] + 1))
	e += f / c[g + i]
print(e)

Submission status: Time Limit Exceeded

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

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

for l in range(0,K):
     m[l] = (1+m[l])/2
n = sum(m)
print(n)

Submission status: Time Limit Exceeded

Solution code:
N,K = (int(x) for x in input().split())
P = list(int(x) for x in input().split())

for i in range(N):
    sam = P[i]
    P[i] = (sam+1)/2

ans = 0
total = 0

for i in range(N-K+1):
    total = sum(P[:K+i]) - sum(P[:i])

    if ans < total:
        ans = total

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p_list = list(map(int, input().split()))
max_val = 0

for i in range(n):
    p_list[i] = (1 + p_list[i]) * 0.5

for j in range(n-k+1):
    max_val = max(max_val, sum(p_list[j:j+k]))
        
print(max_val)

Submission status: Time Limit Exceeded

Solution code:
N,K = (int(x) for x in input().split())
P = list(int(x) for x in input().split())

for i in range(N):
    sam = P[i]
    P[i] = (sam+1)/2

total = [0] * (N-K+1)

for i in range(N-K+1):
    total[i] = sum(P[:K+i]) - sum(P[:i])

print(max(total))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N, K = LI()
p = LI()
ps = []
for i in range(N):
    ps.append((p[i] + 1) / 2)

anss = []
for i in range(N - K + 1):
    anss.append(sum(ps[i : i + K]))
print(max(anss))

Submission status: Time Limit Exceeded

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

exp_sum = []
sum_max = 0
exp1 = 0
for j in range(0,len(p)-k+1):
    sum_each = 0
    exp1 = 0
    sum1 = 0
    for i in range(j,j + k):
        sum1 += p[i]
        if sum1 >= sum_max:
            break
    if sum_max <= sum1:
        sum_max = sum1
        for i in range(j,j + k):
            sum_each = 0.5 * p[i] * (p[i] + 1)
            exp1 += sum_each/p[i]
        exp_sum.append(exp1)
print(max(exp_sum))

Submission status: Time Limit Exceeded

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

exp_sum = []
sum_max = 0
exp1 = 0
for j in range(0,len(p)-k+1):
    sum_each = 0
    exp1 = 0
    sum1 = 0
    for i in range(j,j + k):
        sum1 += p[i]
        sum_max = max(sum1,sum_max)
        if sum1 >= sum_max:
            break
    if sum_max <= sum1:
        for i in range(j,j + k):
            sum_each = 0.5 * p[i] * (p[i] + 1)
            exp1 += sum_each/p[i]
        exp_sum.append(exp1)
print(max(exp_sum))

Submission status: Time Limit Exceeded

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

exp_sum = []
sum_max = 0
exp1 = 0
for j in range(0,len(p)-k+1):
    sum_each = 0
    exp1 = 0
    sum1 = 0
#if k == 1:
#for k in range()
#sum1 += sum(p[0:k])
#exp1 = sum1/p[0]
#exp_sum.append(exp1)
#else:
    for i in range(j,j + k):
        sum1 += p[i]
        sum_max = max(sum1,sum_max)
    if sum_max <= sum1:
        for i in range(j,j + k):
            sum_each = 0.5 * p[i] * (p[i] + 1)
            exp1 += sum_each/p[i]
        exp_sum.append(exp1)
print(max(exp_sum))

Submission status: Time Limit Exceeded

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

exp_sum = []
sum_max = 0
exp1 = 0
for j in range(0,len(p)-k+1):
    sum_each = 0
    exp1 = 0
    sum1 = 0
#if k == 1:
#for k in range()
#sum1 += sum(p[0:k])
#exp1 = sum1/p[0]
#exp_sum.append(exp1)
#else:
    for i in range(j,j + k):
        sum1 += p[i]
    if sum_max < sum1:
        for i in range(j,j + k):
            sum_each = 0.5 * p[i] * (p[i] + 1)
            exp1 += sum_each/p[i]
        exp_sum.append(exp1)
print(max(exp_sum))

Submission status: Time Limit Exceeded

Solution code:
line = input()
line = line.split(" ")
N = int(line[0])
K = int(line[1])
p = input()
p = p.split(" ")
expects = []
for i in range(N-K+1):
  expect = 0
  for k in range(K):
    t = int(p[i+k])
    for e in range(1,t+1):
      expect+=e/t
  expects.append(expect)
print(max(expects))

Submission status: Time Limit Exceeded

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

#print(q[len(q) - 2])
exp_sum = []
exp1 = 0
for j in range(0,len(p)-k+1):
    sum1 = 0
    exp1 = 0
#if k == 1:
#for k in range()
#sum1 += sum(p[0:k])
#exp1 = sum1/p[0]
#exp_sum.append(exp1)
#else:
    for i in range(j,j + k):
        sum1 = 0.5 * p[i] * (p[i] + 1)
        exp1 += sum1/p[i]
    exp_sum.append(exp1)
print(max(exp_sum))

Submission status: Time Limit Exceeded

Solution code:
# ABC154 D - Dice in Line
N,K = map(int, input().split())
P = [int(i) for i in input().split()]

ma = 0
for i in range(0,N-K+1):
  expect = (sum(P[i:i+K])+K)/2
  if ma < expect:
    ma = expect
print(ma)

Submission status: Time Limit Exceeded

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

def ex(p,n):
    return (p[n-1]+1)/2

def sum(p,n,K):
    s=0
    for i in range (0,K):
        s=s+ex(p,n+i)
    return s

max=sum(p,1,K)
for i in range (1,N-K+1):
   if sum(p,i+1,K)>=max:
        max=sum(p,i+1,K)
        
print(max)

Submission status: Time Limit Exceeded

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