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: Wrong Answer

Solution code:
# import sys
# input = sys.stdin.readline
import numpy as np


def main():
    N, K = map(int, input().split())
    ps = np.array(list(input().split()), dtype=int)
    ps = (ps + 1) / 2

    s_list = [0 for _ in range(N)]

    left = 0
    right = K
    s_list[0] = sum(ps[left:right])

    maximum = 0
    for i in range(1, N):
        left = ps[i-1]

        p_right = K + i - 1
        if p_right >= N:
            right = 0
        else:
            right = ps[p_right]

        s_list[i] = s_list[i-1] - left + right
        maximum = max(maximum, s_list[i])

    print(maximum)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

l = list(map(lambda x: x * (x+1) * 1/2 * 1/x, p))

ans = [0] * (n-k+1)
for i in range(n-k+1):
    ans[i] = l[i:i+k]

print(sum(max(ans)))

Submission status: Wrong Answer

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


def expect(n):
    res = sum([i for i in range(1, n+1)]) / n
    return res

ans_sum = sum(p[:k])
idx = 0
for i in range(k, n):
    tmp_sum = ans_sum + p[i] - p[i-k]
    if tmp_sum > ans_sum:
        ans_sum = tmp_sum
        idx = i

ans = list(map(expect, p[idx-k+1:idx+1]))
print(sum(ans))

Submission status: Wrong Answer

Solution code:
n,k=map(int, input().split())
a= list(map(int, input().split()))
maxans=0
for i in range(len(a)-k+1):
  if a[i+k-1]>=a[i]:
    ans=sum(a[i:i+k])
    maxans=max(ans,maxans)
print((maxans+k)/2)

Submission status: Wrong Answer

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

P_ave_sum = []
ave = 0
for p in P:
    ave += (p + 1) / 2
    P_ave_sum.append(ave)



max = -1
for j in range(n - k):
    sum_k = P_ave_sum[j + k] - P_ave_sum[j]
    print(sum_k)
    if sum_k > max:
        max = sum_k

print(max)

Submission status: Wrong Answer

Solution code:
def main():
    n, k = map(int, input().split())
    dice_num = list(map(int, input().split()))
    result = 0

    dice_num.sort(reverse=True)
    for i in range(0, k):
        dice = dice_num[i]
        dice_sum = 0
        for i in range(1, dice + 1):
            dice_sum += i
        if dice_sum != 0:
            result += dice_sum / dice

    print(result)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

sums = []
s = 0
for i in range(N):
  s += calc(P[i])
  sums.append(s)

max_value = -1
max_index = -1

for i in range(N - K + 1):
  s = sums[i+K-1] - sums[i-1]
  max_value = max(max_value, s)
  if max_value == s:
    max_index = i

print(max_value)
# print(sum([calc(P[i]) for i in range(max_index, max_index + K)]))

Submission status: Wrong Answer

Solution code:
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
import itertools
from functools import reduce
from operator import mul

f = [int(s) for s in stdin.readline().rstrip().split()]
N = f[0]
K = f[1]
p = list(map(lambda x: 1/2+x/2, [int(s)
                                 for s in stdin.readline().rstrip().split()]))
past = -2000
for el in range(N - K + 1):
    data = copy.copy(p)
    if el == 0:
        past = 0
        continue
    if p[el - 1] < p[el + K - 1]:
        past = el
print(sum(data[past: past + K]))

Submission status: Wrong Answer

Solution code:
#D - Dice in Line
N,K = map(int,input().split())
p = list(map(int, input().split()))
S = [0]*N
sum = 0
sum_t = 0
S[0] = (1+p[0])/2

if N == 1:
    print(S[0])
    exit()
else:
    pass

for i in range(N-1):
    S[i+1] =S[i]+(1+p[i+1])/2

for j in range(N-K):
    sum_t = S[j+K]-S[j]
    if sum_t >= sum:
        sum = sum_t
    else:
        pass

print(sum)

Submission status: Wrong Answer

Solution code:
N,K,*P = map(int,open(0).read().split())
m = [0]*N
E = [((n+1))/2 for n in range(1,1001)]
print(E[:N])
for i in range(0,N-K+1):
  tmp_sum = 0
  for j in range(K):
    tmp_sum+=E[P[i+j]-1]
  m[i]=tmp_sum
print(max(m))

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
p = list(map(int, input().split()))
m = max(p)
h = [0]*(m+1)
h[1] = 1
for i in range(1,m):
    h[i+1] = h[i]+0.5
ans = sum = 0
for i in range(n):
    if i>=k:
        sum = sum-h[p[i-k]]+h[p[i]]
        if ans<sum: ans=sum
    else:
        sum += h[p[i]]
        if i==k: ans=sum
print(ans)

Submission status: Wrong Answer

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

for i in range(N-K+1):
    m = sum(p[i:i+K])
    if m > max_l:
        max_l = m
        Max_l = p[i:i+K]

L = list(map(lambda x:x+1,Max_l))


print(L)
print(sum(L)/2)

Submission status: Wrong Answer

Solution code:
n,k=map(int, input().split())
p=[(int(i)+1.0)/2.0 for i in input().split()]
ans=0
for i in range(k):ans+=p[i]
tmp1=ans
for i in range(k, n-k+1):
  tmp2 = (tmp1- p[i-k])+p[i]
  ans = max(ans, tmp2)
  tmp1=tmp2
print('{:.12f}'.format(ans))

Submission status: Wrong Answer

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

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

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: Wrong Answer

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

result = 0
for p in sorted(P, reverse=True)[:K]:
    result += 0.5 * p + 0.5
print(result)

Submission status: Wrong Answer

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.0
for ii in range(N-K):
    kk=max(kk,sum(p[ii:K+ii]))
ans=0.5*((kk)+K)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#154 d
def kitaichi(x):
    return (x+1)/2

n,k=map(int,input().split())
p=list(map(int,input().split()))
ans=0
for i in range(n-k+1):
    s=0
    for j in range(k):
        print(p[i+j])
        s+=kitaichi(p[i+j])
    print("----")
    if s>=ans:
        ans=s
print(ans)

Submission status: Wrong Answer

Solution code:
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
import itertools
from functools import reduce
from operator import mul

f = [int(s) for s in stdin.readline().rstrip().split()]
N = f[0]
K = f[1]
p = list(map(lambda x: 1/2+x/2, [int(s)
                                 for s in stdin.readline().rstrip().split()]))
past = -2000
for el in range(N - K + 1):
    data = copy.copy(p)
    if el == 0:
        continue
    if p[el - 1] < p[el + K - 1]:
        past = el
print(sum(data[past: past + K]))

Submission status: Wrong Answer

Solution code:
n, k = list(map(int,input().strip().split()))
p = list(map(int,input().strip().split()))
for i in range(n):
    temp = p[i]
    tem = 0
    for j in range(temp + 1):
        tem += j
    p[i] = float(tem/temp)
    tem = 0
ans = 0
anss = 0
for l in range(k):
    anss += p[l]
for m in range(n - k):
    temp = anss - p[m] + p[m + k]
    anss = temp
    if ans <= temp:
        ans = temp
print(ans)

Submission status: Wrong Answer

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

max = 0
ite = N - K + 1
max = -1000
for i in range(ite):
    tmp = p[K+i-1]-p[i]
    if tmp > max:
        max = tmp
        index = i

E = [None]*K
for i in range(K):
    E[i] = sum(range(1, p[index+i]+1))/p[index+i]
print(sum(E))

Submission status: Wrong Answer

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

def E(a):
    return a*(a+1)/2/a

new_p = [E(i) for i in p]
box=[]
for i in range(k):
    s = sum(new_p[i:i+k])
    box.append(s)
    if i+k == len(new_p)+1:
        break
print(max(box))

Submission status: Wrong Answer

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

sum_num = 0
j = 0
ans = 0

num_array = [0] * K
for i in range(K):
    sum_num += p[i]
    num_array[i] = p[i]
    
for i in range(1, N-K+1):
    j = i+K-1
    temp = sum_num-p[i-1]+p[j]
    if temp > sum_num:
        num_array = p[i:j+1]
        sum_num = temp
        
for i in range(K):
    ans += (num_array[i]+1) / 2
print(ans)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
saidai = 0
wa =[None]*n
wa_2 = 0
for i in range(n):
    wa[i] = sum(p[:i+1])
for j in range(n-k):
    wa_2 = wa[j+k]-wa[j]
    if wa_2 > saidai:
        saidai = wa_2
kitai = (1/2)*(k+saidai)
print(str(kitai))

Submission status: Wrong Answer

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

l = list(map(lambda x: x * (x+1) * 1/2 * 1/x, p))

ans = [0] * (n-k+1)
for i in range(n-k+1):
    ans[i] = l[i:i+k]

print(ans)
print(sum(max(ans)))

Submission status: Wrong Answer

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

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

sums = []
s = 0
for i in range(N):
  s += P[i]
  sums.append(s)

max_value = -1
max_index = -1

for i in range(N - K + 1):
  s = sums[i+K-1] - sums[i]
  max_value = max(max_value, s)
  if max_value == s:
    max_index = i

print(sum([calc(P[i]) for i in range(max_index, max_index + K)]))

Submission status: Wrong Answer

Solution code:
def main():
    hoge = list(map(int, input().split()))
    huga = list(map(int, input().split()))
    suma = 0
    ima = 0
    for i,h in enumerate(huga):
        if i+hoge[1] <= hoge[0]:
            if suma < sum(huga[i:i+hoge[1]]):
                suma = sum(huga[i:i+hoge[1]])
                ima = i
    inter_list = huga[ima:ima+hoge[1]]
    print(inter_list)
    result = 0
    for i,h in enumerate(inter_list):
        result = result + sum(list(range(1,inter_list[i]+1)))/inter_list[i]
    print(result)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
L=list(map(int,input().split()))
A=[0]*N


for i in range(N):
    t=(L[i]+1)*L[i]/2*(1/L[i])
    A[i]=t
s=0
t=sum(A[:K])
for i in range(N-K):
    t+=(A[i+K]-A[i])
    s=max(s,t)

print(s)

Submission status: Wrong Answer

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

def main():
    N,K = map(int,input().split())
    p = list(map(int,input().split()))
    tmp = p[:K]
    maxp = sum(tmp)
    index = 0
    for i in range(K,N):
        next = maxp - p[i-K] + p[i]
        if next >= maxp:
            maxp = next
            index = i
    tmp = p[index-K+1:index+1]
    print(sum(list(map(DE,tmp))))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

answer = []
for i in range(0,N):
    #print(list(range(1,p[i]+1)))
    ev = sum(range(1,p[i]+1))/p[i]
    answer.append(ev)
total = 0
for i in range(0,N-K):
    total = max(total, sum(answer[i:i+K]))
print(total)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
p=list(map(int,input().split()))
ans=0
bns=0
cns=0
dns=0
for i in range(N):
  p[i]=(p[i]+1)/2
for i in range(N//K):
  ans=max(ans,sum(p[i:i+K]))
  bns=max(bns,sum(p[N-i-K:N-i]))
  cns=max(ans,bns)
  dns=max(dns,cns)
print(dns)

Submission status: Wrong Answer

Solution code:
#D - Dice in Line
N,K = map(int,input().split())
p = list(map(int, input().split()))
S = [0]*N
sum = 0
sum_t = 0
S[0] = (1+p[0])/2
for i in range(N-1):
    S[i+1] =S[i]+(1+p[i+1])/2

for j in range(N-K):
    sum_t = S[j+K]-S[j]
    if sum_t >= sum:
        sum = sum_t
    else:
        pass

print(sum)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
s = 0
for i in range(0,K):
    s = s+p[i]
r = s
for i in range(0,N-K):
    t = s+p[i+K]-p[i]
    if s < t:
        r = t
    s = t
print ((r+K)/2)

Submission status: Wrong Answer

Solution code:
from collections import deque

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

exps = [-1] * 1001
seed = 0
for i in range(1, 1001):
    seed += i
    exps[i] = seed / i

total = 0
heads = deque()
for k in range(K):
    p = P[k]
    exp = exps[p]
    total += exp
    heads.append(exp)
ans = 0
for k in range(K, N):
    exp = exps[P[k]]
    head = heads.popleft()
    heads.append(exp)
    total = total - head + exp
    ans = max(ans, total)

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
from collections import deque
import copy


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]


def fetch_ints_inputs(times):
    return [fetch_int_input() for _ in range(times)]


N, K = fetch_int_input()
p = fetch_int_input()

d = deque(p[0:K])
max_d = d
max_num = sum(d)

for i in range(N - K + 1):
    d.popleft()
    d.append(p[i + K - 1])
    sum_nums = sum(d)

    if max_num < sum_nums:
        max_num = sum_nums
        max_d = copy.deepcopy(d)


ave_nums = [(i + 1) / 2 for i in max_d]

print(sum(ave_nums))

Submission status: Wrong Answer

Solution code:
A = list(map(int , input().split()))
B = list(map(int , input().split()))

SS = {sum(B[i:i+A[1]]):B[i:i+A[1]] for i in range(len(B)-A[1]+1)}
tes = 0
for i in range(len(max(SS.values()))):
    dice = list(range(1,max(SS.values())[i]+1))
    ex = sum([1/len(dice)*x for x in dice])
    tes += ex
print(tes)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

tmp_max = 0
tmp_pair = []
for i in range(len(p)-K+1):
    #print(p[i:i+3])
    if sum(p[i:i+K]) > tmp_max:
        # 最大値更新
        tmp_max=sum(p[i:i+K])
        # 最大値のペアを変更
        tmp_pair=p[i:i+K]
        
print("tmp_max", tmp_max)
print("tmp_pair",tmp_pair)


def kitaichi(dice):
    dice = range(1,dice+1)#サイコロの事象
    ex = 0#期待値を演算するための変数
    p = 1/len(dice)#サイコロの確率

    for x in dice:
        px = p*x
        ex += px

    #print("EX = ",ex)
    return ex

result = 0
for i in range(K):
    result += kitaichi(tmp_pair[i])
    
print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int, input().split())
l=list(map(int, input().split()))
s=[0]
for i in range(n-k):
    se=l[i:i+k]
    if sum(se)>sum(s):
        s=se

ans=(sum(s)+k)/2
print(ans)

Submission status: Wrong Answer

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

p.sort()
p = p[-k:]
m = p[-1]
ans = 0
for i in p:
  if i%2 == 0:
    ans += ((i+1) * i//2)/i
  else:
    ans += ((i+1) * (i//2) + (i//2) + 1)/i
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    N, K = map(int, input().split(" "))
    p = list(map(int, input().split(" ")))
    exceptation_sum = [0] * N
    answer = 0
    for i in range(N):
        if not i == 0:
            exceptation_sum[i] = (p[i] + 1) / 2 + exceptation_sum[i - 1]
        else:
            exceptation_sum[i] = (p[i] + 1) / 2
    for i in range(N - K):
        answer = max(answer, exceptation_sum[i + K] - exceptation_sum[i])
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

ans = 0
place, num = 0,0
for i in range(len(p)-k):
    if sum(p[i:i+k]) >= num:
        place,num = i,sum(p[i:i+k])


for i in p[place:place+k]:
    ans += (i+1)/2
else:
    print(ans)

Submission status: Wrong Answer

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

from collections import deque
p_dq = deque(P[0:K-1], K)

max_E = 0
for i in range(2,N):
    p_dq.append(P[i])
    tmp_E = (sum(p_dq) + K) / 2
    if tmp_E > max_E:
        max_E = tmp_E

print(max_E)

Submission status: Wrong Answer

Solution code:
N, K = [int(i) for i in input().split(" ")]
dice_nums = [(int(i)+1)/2 for i in input().split(" ")]
idx = 0
for i in range(N-K):
    if dice_nums[i] < dice_nums[i+K]:
        idx = i + 1
print(sum(dice_nums[idx:idx+K]))

Submission status: Wrong Answer

Solution code:
import numpy as np

def resolve():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))

    best_idx = 0
    best_sum = 0
    best_ps = []

    cs = np.cumsum(P)
    
    for i in range(K-1, N):
        s = cs[i] - cs[i-K+1]
        if s > best_sum:
            best_sum = s
            best_idx = i

    def calc(p):
        pi = range(1, p+1)
        return sum(pi) / len(pi)

    p_sum = 0
    for i in range(K):
        p_sum += calc(P[best_idx - i])

    print(p_sum)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
N, K = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
d = 0
e = []

for i in range(len(b)):
    d = d + b[i]
    c.append(d)

for i in range(len(b) - K):
    e.append(c[i + K] - c[i] + K)
if N==K:
    print(c[-1] - c[0])
else:    
    print(max(e)/2)

Submission status: Wrong Answer

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

zeros = [0] * nk[1]

seq4search = zeros + p

for i in range(nk[1], nk[0] + nk[1]):
    seq4search[i] = (seq4search[i] + 1) / 2
    print(i, sum(seq4search[i - nk[1] + 1:i + 1]))
    if ans < sum(seq4search[i - nk[1] + 1:i + 1]):
        ans = sum(seq4search[i - nk[1] + 1:i + 1])

print(ans)

Submission status: Wrong Answer

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

def main(N, K, P):
    S = [0] * N
    E = [0] * N
    for i in range(N):
        n = P[i]
        S[i] = n * (n+1)/2/n
    a = 0
    E[K-1] = sum(S[:K])
    for i in range(K, N):
        E[i] = E[i-1] - S[i-K] + S[i]
        a = max(a, E[i])
    return a
print(main(N, K, P))

Submission status: Wrong Answer

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

exp = 0e0
max = 0e0

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


print(max)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,K=list(map(int,input().split()))
p=list(map(int,input().split()))
p=list(map(lambda x:(x+1)/2, p))
p_cs=[0]
p_cs.extend(np.cumsum(p))
max_exp=0
print(p_cs)
for i in range(N-K+1):
  exp=p_cs[i+K]-p_cs[i]
  if exp>max_exp:
    max_exp=exp
print(max_exp)

Submission status: Wrong Answer

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

e_nums = [(i+1)/2 for i in nums]

sum_e = []
for i in range(n):
  if i+k <= n-1:
    sum_e.append(sum(e_nums[i:i+k]))
  else:
    sum_e.append(sum(e_nums[i:-1]))

print(max(sum_e))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main(n,k,p):
    res = 0
    #期待値リスト
    kitai = [0] * n
    ruiseki = [0] * n
    kitai[0] = (p[0] + 1) / 2
    ruiseki[0] = kitai[0]
    if n == 1:
        return kitai[0]
    else:
        val = ruiseki[0]
        for i in range(1, len(p)):
            kitai[i] = (p[i] + 1) / 2
            ruiseki[i] = ruiseki[i-1] + kitai[i]
    for i in range(k-1, len(ruiseki)):
        res = max(res, ruiseki[i] - ruiseki[i-k])
    return res


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

Submission status: Wrong Answer

Solution code:
c,d=map(int,input().split())
a=[int(x) for x in input().split()]
b=a.index(max(a))
b1=[]
b2=[]
for i in range(d):
    b1.append(a[b+i])
    if b+i==len(a)-1:
        break
for i in range(d):
    b2.append(a[b-i])
    if b-i==0:
        break
c1=max(b1,b2)
tot=0
for i in c1:
    tot+=sum(range(1,i+1))/i
print(tot)

Submission status: Wrong Answer

Solution code:
def get_expected_value(p):
    return (p + 1) / 2.0


N, K = list(map(int, input().split()))
p = list(map(float, input().split()))
expected_value_list = list(map(get_expected_value, p))
if len(p) == K:
    q = expected_value_list
    print(sum(q))
else:
    q = [expected_value_list[i:i + K] for i in range(len(p) - K - 1)]
    print(max(map(sum, q)))

Submission status: Wrong Answer

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


#pp = sorted(p)
#p.sorted()

ans = 0
place, num = 0,0
for i in range(len(p)-k):
    if sum(p[i:i+k]) >= num:
        place,num = i,sum(p[i:i+k])


for i in p[place:place+k]:
    ans += (i+1)/2
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
p=list(map(float,input().split()))
x=[0.0]*n
for i in range(n):
	x[i]=(p[i]*(p[i]+1)/2)/p[i]
v=[0.0]*(n-k+1)
print(x)
for i in range(n-k+1):
	if(i!=0):
		v[i]=v[i-1]-x[i-1]+x[i+k-1]
	else:
		for j in range(k):
			v[0]+=x[i+j]
print(max(v)+0.000000001)

Submission status: Wrong Answer

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

l = N - K + 1

max_list = []
max_value = 0

for v in range(l):
  check_list = P[v:v+K]
  check = sum(check_list)
  if (max_value < check):
    max_list = check_list

result = 0
for i in max_list:
  i_re = 0
  for j in range(i + 1):
    i_re += j
  result += i_re / i

print(result)

Submission status: Wrong Answer

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

sum = 0
for i in range(NK[1]):
    sum += P[i]

tmp = NK[1]
for i in range(NK[1], NK[0]):
    tmp = P[i]
    tmp = P[i - NK[1]]
    if (P[i] > P[i - NK[1]]):
        sum = 0
        for j in range(NK[1]):
            sum += P[i - j]

print((sum + NK[1]) / 2)

Submission status: Wrong Answer

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

for i in range(N):
    k = (1/2*p[i]*(p[i]+1))/p[i]
    pp.append(k)
for j in range(K):
    kk = sum(pp[j:K+j])
    total.append(kk)
print(max(total))

Submission status: Wrong Answer

Solution code:
import numpy as np

def dice():
    n, k = map(int, input().split())
    p = np.asarray(list(map(int, input().split())))
    pp = np.zeros(n)
    for i in range(n):
      pp[i] = p[i]*(p[i]+1)/(2*p[i])

    ans = np.sum(pp[0:k])
    tmp = np.sum(pp[0:k])
    for i in range(1, n-k):
        tmp = tmp - pp[i-1] + pp[i+k]
        if ans < tmp:
            ans = tmp
    print(ans)

if __name__ == '__main__':
    dice()

Submission status: Wrong Answer

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

ind = K-1
temp, maxA = sum(P[:K]), sum(P[:K])
sumA = [temp]
#print(range(K,N))
for i in range(K,N) :
    temp = temp-P[i-K]+P[i] 
#    print(temp)
    if temp > maxA:
        ind = i
#print(ind)

sol=0
for j in range(ind-K+1,ind+1) :
    sol += (P[j]+1)/2 
print(float(sol))

Submission status: Wrong Answer

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

max_v = P[:k]

j = 0
cum = 0
cum_cnt = 0
for i in range(k, n):
  cum += P[i]
  cum_cnt += 1
  if cum/cum_cnt > P[j]:
    cum = 0
    cum_cnt = 0
    j=i-k+1
              
max_v = P[j:j+k]

ans=0
for i in max_v:
  ans+=(i+1)/2

#import numpy as np

#print((np.sum(max_v[j:j+k])+k)/2)
print(ans)
#print(max_v)

Submission status: Wrong Answer

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

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

dp = [0 for n in range(N)]

for i in range(K):
    dp[i] = (mylist[i]+1)/2
dp[K-1] = sum(dp[0:K])

myans = 0
for n in range(K,N):
    dp[n] = (mylist[n]+1)/2 + dp[n-1] - (mylist[n-K]+1)/2 
    if myans < dp[n]:
        myans = dp[n]
print(myans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

import sys
import numpy as np
from collections import deque
from itertools import combinations
sys.setrecursionlimit(10**9)



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

    sum_0 = 0
    for i in range(K):
        sum_0 += p[i]


    sum_n = sum_0
    max = sum_0
    print(sum_n)
    for i in range(N-K): # i+1
        sum_n = sum_n + p[i+K] - p[i]
        print(sum_n)
        if max < sum_n:
            max = sum_n

    ans = (K + max) / 2
    print("{0:.6f}".format(ans))

if __name__ == "__main__":
  main()

Submission status: Wrong Answer

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):
    tmp = 0
    for j in range(1, p[i] + 1):
        tmp += j
    kitai.append(tmp / p[i])
#print(kitai)
kitai.sort()
#print(kitai)
"""
ans = 0
for i in range(n - k):
    tmp2 = 0
    for j in range(i + k):
        tmp2 += kitai[j]
    print(tmp2)
    if ans < tmp2:
        ans = tmp2
print(ans)

p.sort()
kitaichi = []
for i in range(n - k, n):
    tmp = 0
    for j in range(1, p[i] + 1):
        tmp += j
    kitaichi.append(tmp / p[i])
print(sum(kitaichi))
"""

ans = 0
for i in range(n - k, n):
    ans += kitai[i]
print(ans)

Submission status: Wrong Answer

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

m=max(p)

idx=[i for i, x in enumerate(p) if x == m]

arr=[]

for loc in idx:
  for i in range(k):
    try:
      arr.append((sum(p[loc-k+i+1:loc+i+1])+k)/2)
    except:
      pass

print(max(arr))

Submission status: Wrong Answer

Solution code:
def calc(A):
    res = 0
    res = (1+A)/2
    return res
    
N, K = map(int, input().split())
P = list(map(int, input().split()))
res = 0
for i in range(N-K+1):
    part = 0
    part = sum(P[i:i+K])
    print(P[i:i+K])
    if res < part:
        res = part
        ans = 0
        for j in range(K):
            ans += calc(P[i+j])
print(ans)

Submission status: Wrong Answer

Solution code:
def findWays(m,n,x): 
    table=[[0]*(x+1) for i in range(n+1)] #Initialize all entries as 0 
      
    for j in range(1,min(m+1,x+1)): #Table entries for only one dice 
        table[1][j]=1
          
    # Fill rest of the entries in table using recursive relation  
    # i: number of dice, j: sum 
    for i in range(2,n+1): 
        for j in range(1,x+1): 
            for k in range(1,min(m+1,j)): 
                table[i][j]+=table[i-1][j-k] 
      
    #print(dt) 
    # Uncomment above line to see content of table 
      
    return table[-1][-1] 
      
S, N=  [int(x) for x in input().split()]
P =  [int(x) for x in input().split()]
max_value = []
for i in P: 
    max_value.append(findWays(S,N,i))
    
print(sum(max_value))

Submission status: Wrong Answer

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

#初期 
SUM = sum(P[0:K])
M=0

for i in range(N - K + 1):
    if P[i] < P[i + K - 1]:
        _SUM=sum(P[i:i + K])
        if SUM < _SUM:
            SUM = _SUM
            M = i

EXP_V = (K + SUM)/2
print(EXP_V)

Submission status: Wrong Answer

Solution code:
def func(x):
    return x if x==1 else (x+1)/2

n, k = map(int, input().split())
P = list(map(func, map(int, input().split())))
r = 0
t = sum(P[0:k])
for i in range(n-k):
    t = t-P[i]+P[i+k]
    r = r if r>t else t
print(r)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,K=list(map(int,input().split()))
p=list(map(int,input().split()))
p=list(map(lambda x:(x+1)/2, p))
p_cs=[0]
p_cs.extend(np.cumsum(p))
max_exp=0
print(p_cs)
for i in range(N-K):
  exp=p_cs[i+K]-p_cs[i]
  if exp>max_exp:
    max_exp=exp
print(max_exp)

Submission status: Wrong Answer

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


Msum=0
tmp=sum(p[0:k])

for i in range(1,n-k):
    a=p[i-1]
    b=p[i+k]
    tmp=tmp-a+b
    Msum = max(tmp,Msum)

print((Msum+k)/2)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
p.sort(reverse=True)
def f(n):
    return (n+1)/2
ans=[]
for i in range(K):
    ans.append(f(p[i]))
print(sum(ans))