Problem:


Score : 400 points

Problem Statement

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

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

Constraints

1 ≤ K ≤ N ≤ 200000

1 ≤ p_i ≤ 1000

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
p_1 ... p_N

Output

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

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

Sample Input 1

5 3
1 2 2 4 5

Sample Output 1

7.000000000000

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

Sample Input 2

4 1
6 6 6 6

Sample Output 2

3.500000000000

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

Sample Input 3

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

Sample Output 3

32.000000000000



Sample input:
5 3
1 2 2 4 5


Sample output:
7.000000000000

Submission status: Runtime Error

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

ans=[]

for i in p:
    ex.append(()

for i in range(N-K+1):
    ans.append(sum(ex[i:i+K]))
    
print(max(ans))

Submission status: Runtime Error

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):
        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: Runtime Error

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)-2)])
print(p_mean_sum_max)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

nk = [int(s) for s in input().split()]
n, k = nk[0], nk[1]
arr = [int(s) for s in input().split()]
if k == 0:
    print(0)
else:
    maxsum = -100000
    currsum = 0
    maxstart = 0
    start, end = 0, k-1
    for i in range(k):
        currsum += arr[k]
    while True:
        if currsum > maxsum:
            maxsum = currsum
            maxstart = start
        if end == n-1:
            break
        currsum += arr[end+1]
        currsum -= arr[start]
        start += 1
        end += 1
    ret = 0
    for i in range(maxstart, maxstart+k):
        if arr[i] == 0:
            ret += 0
        else : ret += sum_n(arr[i])/arr[i]
    print(ret)

Submission status: Runtime Error

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

nk = [int(s) for s in input().split()]
n, k = nk[0], nk[1]
arr = [int(s) for s in input().split()]

maxsum = -100000
currsum = 0
maxstart = 0
start, end = 0, k-1
for i in range(k):
    currsum += arr[k]
while True:
    if currsum > maxsum:
        maxsum = currsum
        maxstart = start
    if end == n-1:
        break
    currsum += arr[end+1]
    currsum -= arr[start]
    start += 1
    end += 1
ret = 0
for i in range(maxstart, maxstart+k):
    ret += sum_n(arr[i])/arr[i]
print(ret)

Submission status: Runtime Error

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

def cal_p(x):
    return x*(x+1)/2/x

tmp = []
tmp_sum = []
# ans = 0
for i in range(n):
    tmp. append(cal_p(pl[i]))
    if i >= k:
        tmp_sum.append(sum(tmp[i+1-k:i+1]))

print(max(tmp_sum))

Submission status: Runtime Error

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


def f(x):
    return sum(range(x + 1)) / x


s = []

for i in range(n-k):
    s.append(sum([sum(range(p[i + j] + 1)) / p[i + j] for j in range(k)]))

print("{:.13f}".format(max(s)))

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
s = sum(p[:K])
m = sum(p[:K])
for i in range(K, N + 1):
    s = s - p[i - K] + p[i]
    if s >= m:
      m = s
print((m + K) / 2)

Submission status: Runtime Error

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

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

wa = sum(p_list[0:k])

for j in range(n-k):
    wa = wa + p_list[j+k] - p_list[j]
    ans = max(ans, wa)
    
print(ans)

Submission status: Runtime Error

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(f'{ans:.10f}')

Submission status: Runtime Error

Solution code:
def func_d(n):
    if n == 1:
        return 1
    else:
        return n + func_d(n-1)

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

hp = []
for i in P:
    hp.append(func_d(i)/i)
    
A= [0]
for i in hp:
    A.append(A[-1]+i)
 
ans = []
for i in range(K, N+1):
    ans.append(A[i] - A[i-K])
    
print(max(ans))

Submission status: Runtime Error

Solution code:
A = list(map(int, input().split()))
B = list(map(int, input().split()))
k = [(i+1)/2 for i in B]
h = []
z = []
m = 0
for l in range(A[0]):
  m = m + k[l]
  h.append(m)
for l in range(A[1], A[0]):
	x = h[l] - h[l-(A[1])]
	z.append(x)
print(max(z))

Submission status: Runtime Error

Solution code:
# 期待値
def func_d(n):
    if n == 1:
        return 1
    else:
        return n + func_d(n-1)

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

# 累積和
A = [0]
for i in P:
    A.append(A[-1]+i)
    
ans = []
for i in range(N-K+1):
    ans.append(A[i+K]-A[i])
print(max(ans))

Submission status: Runtime Error

Solution code:
# 期待値
def func_d(n):
    if n == 1:
        return 1
    else:
        return n + func_d(n-1)

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

# 累積和
A = [0]
for i in P:
    A.append(A[-1]+i)

ans = []
for i in range(K, N+1):
    ans.append(A[i] - A[i-K])
    
print(max(ans))

Submission status: Runtime Error

Solution code:
# 期待値
def func_d(n):
    if n == 1:
        return 1
    else:
        return n + func_d(n-1)

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

# 累積和
A = [0]
for i in range(0, N):
    A.append(P[i]+A[i])

ans = []
for i in range(K, N):
    ans.append(A[i] - A[i-K])
    
print(max(ans))

Submission status: Runtime Error

Solution code:
# 期待値
def func_d(n):
    if n == 1:
        return 1
    else:
        return n + func_d(n-1)

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

# 累積和
A = [0]
for i in range(0, N):
    A.append(P[i]+A[i])

ans = []
for i in range(K, N+1):
    ans.append(A[i] - A[i-K])
    
print(max(ans))

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
*d,=list(map(int,input().split()))
 
def e(n):
    ex=(1+n)/2
    return ex
    
dex=[e(i) for i in d]
print(dex)


for i in range(k):
    fst+=dex[i]
print(fst)    

for i in range(n-k):
    x=fst-dex[i]+dex[i+k]
    if x>fst:
        fst=x
        
print(fst)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
c = list(map(int, input().split()))
d = []
for i in range(a - b + 1):
	h = 0
	h = sum(c[i:k + 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: Runtime Error

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

# 期待値
def func_d(n):
    if n == 1:
        return 1
    else:
        return n + func_d(n-1)

AA = []
for i in P:
    AA.append(func_d(i)/i)

# 累積和
A = [0]
for i in range(0, N):
    A.append(AA[i]+A[i])

ans = []
for i in range(K, N+1):
    ans.append(A[i] - A[i-K])
    
print(max(ans))

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
*d,=list(map(int,input().split()))
 
def e(n):
    ex=(1+n)/2
    return ex
    
dex=[e(i) for i in d]

ansl=[]
for j in range(n-k+1):
    ans=dex[j:j+k]
    ansl.append(ans)

ans=0
for i in range(k):
    ans=max(ans,sum(ansl[i]))
    
print(ans)

Submission status: Runtime Error

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

def e(n):
    ex=(1+n)*n/(2*n)
    return ex
 
ansl=[]
for j in range(n-k+1):
    ex=0
    ans=d[j:j+k]
    ansl.append(ans)
    
ans2=ansl[0]
ansum=sum(ansl[0])

for i in range(1,k):
    x=sum(ansl[i])
    if x>ansum:
        ans2=ansl[i]
        ansum=x
    

ansf=0
for y in range(k):
    ansf+=e(ans2[y])
    
print(ansf)

Submission status: Runtime Error

Solution code:
import sys
from itertools import accumulate


def solve():
    N, K = map(int, sys.stdin.readline().split())
    cusum_p = list(accumulate(map(int, sys.stdin.read().split()), initial=0))
    return (max(i - j for i, j in zip(cusum_p[K:], cusum_p[:-K])) + K) / 2


if __name__ == "__main__":
    answer = solve()
    print(answer)

Submission status: Runtime Error

Solution code:
import sys
from itertools import accumulate

N, K = map(int, sys.stdin.readline().split())
cusum = tuple(accumulate(map(int, sys.stdin.read().split()), initial=0))

print((max(i - j for i, j in zip(cusum[K:], cusum[:-K]) + K) / 2)

Submission status: Runtime Error

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; i++) cin >> p[i];
    vector<double> e(n);
    for (int i = 0; i < n; i++) {
        int s = 0;
        for (int j = 1; j <= p[i]; j++) s+=j;
        e[i] = (double) s / p[i];
    }

    double curr = 0;
    for (int i = 0; i < k-1; i++) curr += e[i];
    double best = curr;
    for (int i = k-1; i < n; i++) {
        curr += e[i];
        best = max(best, curr);
        curr -= e[i-k+1];
    }
    cout << best << endl;
    
    return 0;
}

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
  
s = []
sump = 0
for i in range(n):
  sump += (p[i] + 1) / 2
  s.append(sump)
  
ans = set()
for i in range(k, n):
  ans.add(s[i]-s[i-k])
  
if n == 1:
  print(s[0])
else:
  print(max(ans))

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
  
s = []
sump = 0
for i in range(n):
  sump += (p[i] + 1) / 2
  s.append(sump)
  
ans = set()
for i in range(k, n):
  ans.add(s[i]-s[i-1])
  
if n == 1:
  print(s[0])
else:
  print(max(ans))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def tasu(x):
    return x / 2 * (x + 1)

def kitaiti(n , k , p):

    ans = 0
    count = 0
    kitai = [0]*n
    kitaisum = [0]*n
    mod = 10**9+7

    for i in range(n):
        kitai[i] = tasu(p[i]) / p[i]

    for i in range(n):
        if i == 0:
            kitaisum[i] += kitai[i]
        else:
            kitaisum[i] += kitai[i] + kitaisum[i-1]

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

        ans = max(ans , (kitaisum[i+k] - kitaisum[i]))

    return ans

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

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
def expe(n):
  return (n+1)/2
p=[expe(int(x)) for x in input().split()]
l,r=[p[0]]*n,[p[n-1]]*n
for i in range(n-1):
  l[i+1]=l[i]+p[i+1]
  r[n-2-i]=r[n-1-i]+p[n-2-i]
su=sum(p)
ans=max(su-r[k],su-l[n-k-1])
for i in range(1,n-k-1):
  sumk=su-l[i-1]-r[i+k]
  ans=max(sumk,ans)
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

s_max = sum(p[0:k])

for i in range(n-k+1):
  s = s - p[i] + p[i+k]
  if s_max < s:
    s_max = s
    
print(s_max)

Submission status: Runtime Error

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

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

for i in range(n-k+1):
  s = sum(p[i:i+k])
  if s_max < s:
    s_max = s
    
print(e)

Submission status: Runtime Error

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


E = [0] * 1001

total = 0
for i in range(1, 1001):
    total += i
    e = total / i
    E[i] = e

P_to_E = [E[p] for p in P]

candidates = []
candidate = sum(P_to_E[:k])

for i in range(n-k):
    drop = P_to_E[i]
    add = P_to_E[i+k]
    candidate += add - drop
    candidates.append(candidate)

print(max(candidates))

Submission status: Runtime Error

Solution code:
def h(j):
    l = int(j)
    return 0.5 * (l + 1)

n, k = map(int, input().split())
ls = list(map(h, input().split()))
s = [sum(ls[0:i]) for i in range(1,n+1)]
a = s[k] - s[0]
for i in range(0,n-k-1):
    if s[i + k] - s[i] < s[i + k + 1] - s[i + 1]:
        a = s[i + k + 1] - s[i + 1]
print(a)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
ls = list(map(int, input().split()))
lsa = [0.5*(ls[i]+1) for i in range(0,n)]
s = [sum(lsa[0:i]) for i in range(1,n+1)]
a = s[k] - s[0]
for i in range(0,n-k-1):
    if s[i + k] - s[i] < s[i + k + 1] - s[i + 1]:
        a = s[i + k + 1] - s[i + 1]
print(a)

Submission status: Runtime Error

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

val = 0
for i in range(k):
    val += p[i]
point = k-1

cnt = val
for i in range(k,n):
    cnt += p[i] - p[i-k]
    if cnt > val:
        val = cnt
        point = i-k+1
#print(point)

ans = 0
for i in range(k):
    ans += (p[point] + 1) / 2
    point += 1

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
n,k = map(int(input().split()))
p = np.array(list(map(int, input().split())))
m = (p+1)/2
s = sum(m[:k])
r = s
for i in range(n-k):
    s -= m[i]
    s += m[i+k]
    r = max(r,s)
print(r)

Submission status: Runtime Error

Solution code:
from collections import deque

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

sum = 0
ans = 0
for i in range(n):
  deque.append(A[i])
  sum += A[i]
  if len(deque)==k:
    ans = max(ans, (sum+k)/2)
  sum -= deque.popleft()

print(ans)

Submission status: Runtime Error

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

cml_sum = [(P[0]+1)/2.0]
for i in range(1, N):
    cml_sum.append(cml_sum[i-1] + (P[i]+1)/2.0)

ans = cml_sum[K]
for i in range(N-K):
    target = cml_sum[i+K] - cml_sum[i]
    if ans < target:
        ans = target

print(ans)

Submission status: Runtime Error

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

res = sum(p[:K])
res_max = res
for i in range(1, N-K+1):
    res += p[i+K-1] - p[i-1]
    if res > res_max:
        i_max = i

ans = 0
for j in range(K):
    ans += (p[i_max + j] + 1) / 2
print(ans)

Submission status: Runtime Error

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

res = sum(p[:K])
res_max = res
for i in range(1, N-K+1):
    res += p[i+k] - p[i-1]
    if res > res_max:
        i_max = i

ans = 0
for j in range(K):
    ans += (p[i_max + j] + 1) / 2
print(ans)

Submission status: Runtime Error

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

cml_sum = [(P[0]+1)/2.0]
for i in range(1, N):
    cml_sum.append(cml_sum[i-1] + (P[i]+1)/2.0)

ans = cml_sum[K] - cml_sum[0]
for i in range(N-K):
    target = cml_sum[i+K] - cml_sum[i]
    if ans < target:
        ans = target

print(ans)

Submission status: Runtime Error

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

cml_sum = [(P[0]+1)/2.0]
for i in range(1, N):
    cml_sum.append(cml_sum[i-1] + (P[i]+1)/2.0)

ans = 0
for i in range(N-K+1):
    target = cml_sum[i+K] - cml_sum[i]
    if ans < target:
        ans = target

print(ans)

Submission status: Runtime Error

Solution code:
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    int n = nextInt();
    int k = nextInt();
    double[] p = new double[n];
    for(int i=0;i<n;i++){
      p[i] = nextDouble();
    }

    double[] eachK = new double[n-k+1];

    double Sum = 0;

    for(int i=0;i<k;i++){
      Sum += (1+p[i])/2;
    }

    double max = Sum;

    for(int i=1;i<n-k+1;i++){
      Sum -= (1+p[i-1])/2;
      Sum += (1+p[i+k-1])/2;
      max = Math.max(max,Sum);
    }


    System.out.println(max);

  }
  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

  static int nextInt(){
    return Integer.parseInt(sc.next());
  }

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}

Submission status: Runtime Error

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

p_likelihood = [0] * N
for pi in range(N):
    p_likelihood[i] = (p[i] + 1) / 2

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

print(ans)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
li = list(map(int, input().split()))
r = []
ans = []
for x in li:
    a = list(itertools.accumulate(list(range(1,x+1))))
    b = a[-1] / x
    r += [b]
    ans += [sum(r[-K:])]

print(max(ans))

Submission status: Runtime Error

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

for i in range(len(p)-k+1):

    an = 0

    for j in range(k):

        for l in range(1, p[i+j] + 1):
            an += l/p[i+j]

        ans=max(ans,an)

print(max(ans))

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p = [int(i) for i in input().split()]
expp = [(i + 1) / 2 for i in p]
cumu, cumu_expp = 0, []
for i in expp:
    cumu += i
    cumu_expp.append(cumu)

max_expp = 0
for i in range(n - k + 1):
    sumpk = cumu_expp[i + k] - cumu_expp[i]
    if max_expp < sumpk:
        max_expp = sumpk
print(max_expp)

Submission status: Runtime Error

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

window = sum(A[0:K])
max_s = 0
for i in range(N - K):
    window -= A[i]
    window += A[i + K]
    sum_w = sum(window)
    if sum_w > max_s:
        max_s = sum_w
print((max_s+K) / 2)

Submission status: Runtime Error

Solution code:
import numpy
c,d=map(int,input().split())
a=[int(x) for x in input().split()]
b1=0
b2=0
kitaiti=[(1+i)/2 for i in a]
ruisekiwa=numpy.cumsum(kitaiti)
i=0
while True:
    b1=ruisekiwa[i+d]-ruisekiwa[i]
    b2=max(b1,b2)
    if len(ruisekiwa)-1==i+d:
        break
    i+=1
print(b2)

Submission status: Runtime Error

Solution code:
def expect(p):
    return (int(p)+1)/2

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

S = [sum(P[:i]) for i in range(1,N+1)]
E = []

for i in range(N-K):
    E.append(S[i+K]-S[i])

print('{:.12f}'.format(max(E)))

Submission status: Runtime Error

Solution code:
import numpy
c,d=map(int,input().split())
a=[int(x) for x in input().split()]
b1=0
b2=0
_=0
kitaiti=[(1+i)/2 for i in a]
ruisekiwa=numpy.cumsum(kitaiti)
kitaisa=[ruisekiwa[i+d]-ruisekiwa[i] for i in range(len(ruisekiwa)-d)]
print(max(kitaisa))

Submission status: Runtime Error

Solution code:
def expect(p):
    return (int(p)+1)/2

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

S = [sum(P[1:i]) for i in range(N)]
E = []

for i in range(N-K):
    E.append(S[i+K]-S[i])

print('{:.12f}'.format(max(E)))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

l = pn[:K]
for i in range(N-K+1):
    l = max(l, l+pn[K+1+i]-pn[i])
ans = (l+K)/2
print(ans)

Submission status: Runtime Error

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

l = pn[:K]
for i in range(N-K+1):
    l = max(l, l+pn[K+1]-pn[i])
ans = (l+K)/2
print(ans)

Submission status: Runtime Error

Solution code:
n,k,*p=map(int,open(0).read().split())
p+=0,
for i in range(n):p[i]-=~p[i-1]
print(max(p[i+k]-p[i-1]for i in range(n-k))/2)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def expect(p):
    return (int(p)+1)/2

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

sum_list = [sum(P[0:K])]
S = [sum(P[0:i]) for i in range(1, len(P)+1)]
E = []

for i in range(N-K):
    E.append(S[i+K]-S[i])

print('{:.12f}'.format(max(E)))

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
p = [(int(i)+1)/2 for i in input().split()] #期待値にして格納

#累積和を求める
for i in range(1,n):
    p[i]=p[i-1]+p[i]
mx = p[k]
for i in range(k,n):
    a = p[i] - p[i-k]
    print(a)
    if a > mx:
        mx = a
        
print(mx)

Submission status: Runtime Error

Solution code:
def expect(p):
    return (int(p)+1)/2

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

sum_list = [sum(P[0:K])]
S = [sum(P[0:i]) for i in range(len(P))]
E = []

for i in range(N-K):
    E.append(S[i+K]-S[i])

print('{:.12f}'.format(max(E)))

Submission status: Runtime Error

Solution code:
def expect(p):
    return (int(p)+1)/2

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

sum_list = [sum(P[0:K])]
S = [sum(P[0:i]) for i in range(len(P))]
E = []

for i in range(N-K):
    print(S[i+K]-S[i])
    E.append(S[i+K]-S[i])

print('{:.12f}'.format(max(E)))

Submission status: Runtime Error

Solution code:
# coding: utf-8

n,k=map(int,input().split())
p=[ int(i) for i in input().split() ]
kitaichi=max_num=0

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

print(max_num)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**6)

def InMap(): return list(map(int, sys.stdin.readline().split(' ')))
def In(): return int(sys.stdin.readline())
def InS(): return sys.stdin.readline()

N, K = InMap()
P = InMap()

print((max([sum(P[i:i+K]) for i in range(N-K)]) + K) / 2)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from itertools import accumulate

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

# 期待値の前計算
expP = [(P[i]+1)/2 for i in range(n)]

# 累積和の計算
acc = [0]+ list(+accumulate(expP)) # 0を忘れずに
print(acc)

# 隣接する K 項の和の計算
ans = 0
for i in range(n-k+1):
  ans = max(ans,acc[i+k]-acc[i])
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from itertools import accumulate

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

# 期待値の前計算
expP = [(P[i]+1)/2 for i in range(n)]

# 累積和の計算
acc = list([0]+accumulate(expP)) # 0を忘れずに
print(acc)

# 隣接する K 項の和の計算
ans = 0
for i in range(n-k+1):
  ans = max(ans,acc[i+k]-acc[i])
print(ans)

Submission status: Runtime Error

Solution code:
A = list(map(int , input().split()))
B = list(map(int , input().split()))
ki = [1+(0.5*(i-1)) for i in B]
print(max([sum(ki[i:i+A[1]]) for i in range(0,len(ki)-A[1])]))

Submission status: Runtime Error

Solution code:
import numpy as np
N, K = [int(i) for i in input().split()]
array = [int(i) for i in input().split()]

ary = np.array([(1 + n) / 2 for n in array])

cumsum = ary.cumsum()

exv.append(cumsum[K-1])
for i in range(N - K):
    exv.append([cumsum[i+K] - cumsum[i]])
    
print(max(exv)[0])

Submission status: Runtime Error

Solution code:
import numpy as np

N,K = map(int,input().split())
p = list(map(int,input().split()))
E = sum(p[0:K])
a = E
for i in range (0,N-K):
  E = E - p[i] + p[i+K]
  if E == max(a,E):
    a = E
    
print((a+K)/2)

Submission status: Runtime Error

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

ary = np.array([(1 + n) / 2 for n in array])

cumsum = ary.cumsum()

exv.append(cumsum[K-1])
for i in range(N - K):
    exv.append([cumsum[i+K] - cumsum[i]])
    
print(max(exv)[0])

Submission status: Runtime Error

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

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

def bubunwa(k):
  subsum = 0
  for i in range(k):
    subsum = subsum + kitaichi(i)
  return subsum

W = []
for j in range(0, N - K):
  P = bubunwa(j + K) - bubunwa(j)
  W.append(P)
  
print(max(W))

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
 
now = sum(p[:K])
saidai = now
for i in range(K, N):
  now -= p[i-K]
  now += p[i+K]
  if now > saidai:
    saidai = now

print('{:.12f}'.format((saidai + K)/2))

Submission status: Runtime Error

Solution code:
# D
import numpy as np
N, K = map(int,input().split())
p = list(map(int,input().split()))

sums=np.cumsum([(s+1)/2 for s in p])

ans=np.max([ sums[i+K]-sums[i] for i in range(N-K)])

print(ans )

Submission status: Runtime Error

Solution code:
def d_dice_in_line():
    from itertools import accumulate
    N, K = [int(i) for i in input().split()]
    P = [int(i) for i in input().split()]

    expected_value = [(p + 1) / 2 for p in P]  # 1~p まで出るサイコロの出目の期待値
    cumsum = [0] + list(accumulate(expected_value))
    return max([cumsum[j + K] - cumsum[j] for j in range(K)])

print(d_dice_in_line())

Submission status: Runtime Error

Solution code:
def main():
    N,K = map(int, input().split())
    p = list(map(int, input().split()))
    esum = [0]*N
    psum = [0]*(N-K)
    esum[0] = p[1]
    for i in range(1,K):
        esum[i] = esum[i-1]+p[i]
    for i in range(K,N):
        esum[i] = esum[i-1]+p[i]
        psum[i-K] = esum[i]-esum[i-K]

    print(  (max(psum)+K)*0.5  )
    return

if __name__=="__main__":
    main()

Submission status: Runtime Error

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

#p = [(n+1)/2 for n in p]
import numpy as np
s = np.cumsum(p)

e=s[K-1]
max_e=(K+e)/2
for i in range(1,N-K):
  e=s[i+K]-s[i]
  e=(K+smax)/2
  max_e = max(max_e, e)
    
print(max_e)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
num_list = list(map(int, input().split()))
k_sum = sum(num_list[0:b])
max_sum = k_sum
for i, j in zip(num_list[0:], num_list[k:]):
    k_sum -= i
    k_sum += j
    max_sum = max(max_sum, k_sum)
out = (max_sum + b) / 2
print(out)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
double E(double x){
  return (x+1.) * x / 2. / x;
}

int main(){
  int N,K;
  cin >> N >> K;
  vector<double> Es(N,0);
  double ans = 0;
  auto itr = Es.begin();
  for(int i=0; i<N; i++){
    cin >> *itr;
    *itr = E(*itr); 
    itr++;
    if(i+1 >= K) ans = max(ans, accumulate(prev(itr,K), itr, 0.0));
  }
  cout << ans << endl;
}