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:
import numpy as np
import copy

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

p1 = np.array(p)
p1 = p1 + 1
p1 = p1 / 2
p2 = copy.copy(p1)

for i in range(k-1):
    p1 = np.vstack([p1, np.roll(p2,i+1)])

sums = np.sum(p1, axis= 0)

print(np.max(sums[k-1:]))

Submission status: Runtime Error

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 = [sum(e_nums[i:i+k]) for i in range(n) if i+k <= n-1]

print(max(sum_e))

Submission status: Runtime Error

Solution code:
import numpypy as np
n, d = list(map(int, input().split()))
a = list(map(int, input().split()))
a = np.array(a)

Max = 0

for i in range(n-d+1):
  Sum = a[i:i+d].sum()
 
  if Sum >= Max:
    Max = Sum
    ans = a[i:i+d]    
  else:
    pass
  
ans = ans*0.5 + 0.5
print(ans.sum())

Submission status: Runtime Error

Solution code:
import math
import itertools
#n = int(input())
#n, d = list(input().split())
n, k= list(map(int, input().split()))
p = list(map(int, input().split()))
point = []
rui = []

def s(n):
    if(n==1):
        return 1
    else:
        return n+s(n-1)


#for は一重まで
for i in range(n):
    point.append(s(p[i])/p[i])
    if i==0:
        rui.append(point[0])
    else:
        rui.append(rui[i-1]+point[i])


m = 0
a = 0
for i in range(n-k+1):
    if i==0:
        a = rui[i+k-1]
    else:
        a = rui[i+k-1]-rui[i-1]
    
   # print(a)
    if a > m:
        m = a



#print(point)
#print(rui)
print(m)

Submission status: Runtime Error

Solution code:
import numpy as np

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


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

Submission status: Runtime Error

Solution code:
import numpy as np
from numba import njit

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

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

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

Submission status: Runtime Error

Solution code:
def solve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    
    base = [i for i in range(1, 1001)]
    l = list(itertools.accumulate(base))
    r = []
    for i in range(0, len(l)):
        r.append(l[i] / (i+1))

    memo = 0
    maxi = 0
    for i in range(N-M+1):
        if maxi < sum(A[i:M+i]):
            maxi = sum(A[i:M+i])
            memo = i

    ans = 0
    for i in A[memo:M+memo]:
        ans += r[i-1]

    return ans

print(solve())

Submission status: Runtime Error

Solution code:
import math
import itertools
#n = int(input())
#n, d = list(input().split())
n, k= list(map(int, input().split()))
p = list(map(int, input().split()))
point = []
rui = []

def s(n):
    if(n==1):
        return 1
    else:
        return n+s(n-1)


#for は一重まで
for i in range(n):
    point.append(s(p[i])/p[i])
    if i==0:
        rui.append(point[0])
    else:
        rui.append(rui[i-1]+point[i])


m = 0
a = 0
for i in range(n-k+1):
    if i==0:
        a = rui[i+k-1]
    else:
        a = rui[i+k-1]-rui[i-1]
    
    print(a)
    if a > m:
        m = a



#print(point)
#print(rui)
print(m)

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
q=[]
r=[]
for i in range(n):
    q[i].append(sum(j for j in range(1,p[i]+1))/p[i])
for i in range(n-k+1):
    r[i].append(sum(q[j] for j in range(i,i+k)))
r.sort(reverse=True)
print(r[0])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
List = list(map(int, input().split()))
score = [1, 1.5, 2, 2.5, 3, 3.5]
max = 0
index = 0
res = 0

for i in range(n-k+1):
    pre = List[i]
    for j in range(k-1):
        pre += List[i+j]
    

    if max < pre:
        index = i
        pre = 0
    else:
        pre = 0
    
#print(index)
for i in range(index, index+k):
    res += score[List[i]-1]
    #print(List[i])

print(res)

Submission status: Runtime Error

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

res = sum(p[0:k])
ans = []
for i in range(k,n):
    if p[i-k]<p[i]:
        res = sum(p[i-k+1:i+1])
        ans = p[i-k+1:i+1]

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

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
array = list(map(int, input().split()))

sum = 0
max = 0
max_index = K

for i in range(K):
    sum += array[i]
    max = sum

for i in range(K, N):
    sum += array[i] - array[i - K]
    if sum > max:
        max = sum
        max_index = i

E = [(array[x] + 1) / 2 for x in range(max_index - K + 1, max_index + 1)]

sum2 = 0
for x in E:
    sum2 += x

print(sum2)

Submission status: Runtime Error

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

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

print(max(s))

Submission status: Runtime Error

Solution code:
import numpy as np


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

candidates = np.array(list(map(int, input().split())))
s = np.convolve(0.5*(candidates+1), np.ones(m), mode='valid')
print(s.max())

Submission status: Runtime Error

Solution code:
import math
from functools import lru_cache

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

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

Submission status: Runtime Error

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



PP = P *0.5+0.5

ans = float(0)
final = 0
repeat = N-K+1
for j in range(repeat):
    ans = 0
    for i in range(K):
        ans = ans+PP[i+j]
        if final <= ans :
            final = ans
        
print(final)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
S=[]
for i in range(N):
  a=float((1+P[i])*P[i]/2)
  S.append(float(a/P[i]))
#print(S)
T=[]
i=1
while i+K<N+1:
  T.append(sum(S[i:i+K]))
  i=i+1
#print(S)
#print(T)
print(max(T))

Submission status: Runtime Error

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

P = []+p
P = list(accumulate(P))

ans = []

if n == 1:
    print((p[0]+1)/2)
else:    
    for i in range(n-k):
        ans.append(P[i+k]-P[i])
    print((max(ans)+k)/2)

Submission status: Runtime Error

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)

print(max(e)/2)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
P = map(int, input().split())
res = -1
for i in range(N-K+1):
  PP = P[i:K+i]
  mp = 0
  for p in PP:
    mp += sum(range(p+1))/float(p)
  if res < mp:
    res = mp

print(res)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
fac = [0] * 3010
fac[0] = 1
if (N >= 1):
    for i in range(1, 1010): fac[i] = i + 1 + fac[i - 1]
# 期待値
#print(p, fac[:max(p)])
exp = [0] * 3010
for i in range(N):
    exp[i] = fac[p[i] - 1] / p[i]
# print(exp)

Ans = 0
ans = [0] * 3000
ans[0] = sum(exp[:K])
for i in range(1, N - K + 1):
    if(i + K == N + 1): break
    ans[i] = ans[i - 1] - exp[i - 1] + exp[i + K - 1]
    # print(ans[i])
    #print(exp[i: i + K])
print(max(ans))

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
fac = [0] * 1010
fac[0] = 1
if (N >= 1):
    for i in range(1, 1010): fac[i] = i + 1 + fac[i - 1]
# 期待値
#print(p, fac[:max(p)])
exp = [0] * 1010
for i in range(N):
    exp[i] = fac[p[i] - 1] / p[i]
#print(exp)

Ans = 0
ans = [0] * N
ans[0] = sum(exp[:K])
for i in range(1, N - K + 1):
    if(i + K == N + 1): break
    ans[i] = ans[i - 1] - exp[i - 1] + exp[i + K - 1]
    #print(ans[i])
    #print(exp[i: i + K])
print(max(ans))

Submission status: Runtime Error

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

expect_value = [0]*N

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

ans = [0] * (N - K + 1))
for i in range(N - K + 1):
    ans[i] = sum(expect_value[i:i+K])
print(max(ans)

Submission status: Runtime Error

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+1):
    a=p[i-1]
    b=p[i+k]
    tmp=tmp-a+b
    Msum = max(tmp,Msum)

print((Msum+k)/2)

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <vector>
#include <iomanip>

using namespace std;

int main(void)
{
    int dices_count, selection;
    vector<double> expects;

    cin >> dices_count >> selection;

    for(int i = 0; i < dices_count; i++){
        int surface;
        cin >> surface;

        expects.push_back(double(surface + 1) / 2);
    }

    double current_exp_sum = 0;
    // initial sum
    for(int i = 0; i < selection; i++){
        current_exp_sum += expects[i];
    }

    double max_exp_sum = current_exp_sum;

    for(int i = selection; i < dices_count; i++){
        current_exp_sum += expects[i];
        current_exp_sum -= expects[i - selection];

        if(max_exp_sum < current_exp_sum){
            max_exp_sum = current_exp_sum;
        }
    }

    cout << setprecision(10) << current_exp_sum << endl;

    return 0;
}

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <vector>
#include <iomanip>

using namespace std;

int main(void)
{
    int dices_count, selection;
    vector<double> expects;

    cin >> dices_count >> selection;

    for(int i = 0; i < dices_count; i++){
        int surface;
        cin >> surface;

        expects.push_back(double(surface + 1) / 2);
        cout << "computed expect: " << double(surface + 1) / 2 << endl;
    }

    double current_exp_sum = 0;
    // initial sum
    for(int i = 0; i < selection; i++){
        current_exp_sum += expects[i];
    }

    double max_exp_sum = current_exp_sum;

    for(int i = selection; i < dices_count; i++){
        current_exp_sum += expects[i];
        current_exp_sum -= expects[i - selection];

        if(max_exp_sum < current_exp_sum){
            cout << "max on " << i << endl;
            max_exp_sum = current_exp_sum;
        }
    }

    cout << setprecision(10) << current_exp_sum << endl;

    return 0;
}

Submission status: Runtime Error

Solution code:
import numpy as np


len_arr, width = map(int, input().split())
dices = np.array(list(map(int, input().split())))

ps = np.array([dices[i:i+width].sum() for i in range(0, len_arr - width + 1)])
idx = ps.argmax()
# target = dices[idx:idx+width]

expected = (dices[idx:idx+width].sum() + width) * 0.5
print(expected)

Submission status: Runtime Error

Solution code:
import numpy as np


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


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

Submission status: Runtime Error

Solution code:
import numpy as np
n, k = map(int, input().split())
v_list = np.array(list(map(int, input().split())))
merge_list = []
for i in range(k):
  merge_list.append(v_list[i:n+1+i-k])
if k > 1:
  merged_arr = np.vstack(merge_list)
  max_val = merged_arr.sum(axis=0).max()
else:
  max_val = merge_list[0].max()
print((max_val+k)/2)

Submission status: Runtime Error

Solution code:
from sys import stdin
#n = int(stdin.readline().rstrip())
n,k = map(int, stdin.readline().rstrip().split())
#S = [list(map(int, stdin.readline().rstrip().split())) for _ in range(h)]#hの定義を忘れずに
p = list(map(int, stdin.readline().rstrip().split()))

l = []
for i in range(n):
    s = 0
    d = p[i]
    for j in range(d):
        s += 1+j
    l.append(s/d)

ans = 0
for i in range(k):
    sums = [l[i+j] for j in range(k)]
    ans = max(sum(sums), ans)
print(ans)

Submission status: Runtime Error

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


ans = 0
for j in range(n - k + 1):
    sum = 0
    for z in range(j,j + k):
        sum += sum([j for j in range(1, p[z] + 1)]) / p[z]
    ans = max(ans, sum)

print(ans)

Submission status: Runtime Error

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

tmp = 0
Ktmp = 0
def Sum(sum, a):
    if a == 1:
        return sum + 1
    else:
        return Sum(sum + a, a - 1)
    
for i in range(N):
    KList.append(Sum(0, PList[i]) / PList[i])

for i in range(N - K + 1):
    for q in range(i, K + i):
        Ktmp += KList[q]
    
    if Ktmp > tmp:
        tmp = Ktmp
    Ktmp = 0

print(tmp)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
A = [0]
for i in range(1, 1000):
    A.append(A[i-1]+i)
S = [0]*n
for j in range(n):
    S[j] = A[p[j]]/p[j]
ANS = [sum(S[a] for a in range(k))]
for i in range(n-k):
    ANS.append(ANS[i]-S[i]+S[k+i])
print(max(ANS))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
#define MOD 1000000007
#define MAX_V 100010
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll junnretu(ll n){
    ll ans=1;
    for (ll i=1;i<=n;i++){
        ans*=i;
    }
    return ans;
}
 
map<ll,ll> prime_factor(ll n){
    map<ll,ll> mp;
    for(ll i=2; i*i<=n; i++){
        while(n % i == 0){
            mp[i]++;
            n /= i;
        }
    }
    if(n != 1) mp[n] = 1;
    return mp;
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

ld kitaiti(ld n,ld x[]){
    ld ans=0;
    for (ll i=0;i<(ll)(n);i++){
        ans+=x[i];
    }
    return ans/n;
}
int main(){
    ll s,k;
    cin >> s >> k;
    ld x[s],b[s];
    for (ll i=0;i<s;i++){
        cin >> x[i];
    }
    for (ll i=0;i<s;i++){
        b[i]=kitaiti((ld)(i+1),x);
        cout << b[i] << endl;
    }
    ll flag=b[0]+b[1]+b[2];
    ll ans=flag;
    for (ll i=k;k<=s;k++){
        flag-=b[i-3];
        flag+=b[i];
        ans=max(flag,ans);
    }
    cout << ans << endl;
    return 0;
}

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np
def resolve():
    n, k = map(int, input().split())
    p = np.array(list(map(int, input().split())))
 
    sums = p[:-2] + p[1:-1] + p[2:]
 
    print((np.max(sums) + k) / 2)
resolve()

Submission status: Runtime Error

Solution code:
from itertools import accumulate
n, k = map(int, input().split())
p = list(map(int, input().split()))
pex = [(1+n)/2 for n in p]
mx = [0] + pex
mx = list(accumulate(mx))

ans = []
for i in range(n-k):
    ans.append(mx[i+k] - mx[i])
print(max(ans))

Submission status: Runtime Error

Solution code:
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n, k = LI()
    ps = LI()
    sum_ = [0]
    for i in range(1, 1000+1):
        sum_.append(sum_[i-1] + i)
    kitai = [ke / (i + 1) for i, ke in enumerate(sum_[1:])]
    kitai2 = [kitai[i-1] for i in ps]
    ans = []
    for i in range(n-k):
        if i == 0:
            ans.append(sum(kitai2[0:0+k]))
        else:
            ans.append(ans[i-1] - kitai2[i-1] + kitai2[i+k-1])
    print(max(ans))



if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def solve(n, k, p):
    E = [(1.0 + p_i)/2 for p_i in p]
    # pprint(E)
    
    ans = 0
    for i in range(n - k + 1):
        # print(i+3)
        ans = max(ans, sum([E[i+j] for j in range(k)]))
        # print(i, sum([E[i+j] for j in range(k)]))
    print(ans)

if __name__ == '__main__':
    n, k = map(int, sys.stdin.readline().strip().split(" "))
    p = list(map(int, sys.stdin.readline().strip().split(" ")))
    solve(n, k, p)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(5000)
n, k = map(int, input().split())
p_lis = list(map(int, input().split()))
def calc_ex(num):
    return (num - 1) * 0.5 + 1
cur_num = 0
for i in range(k):
    cur_num += p_lis[i]
max_nums = cur_num
max_nums_i = i
for i in range(len(p_lis) - k):
    cur_num -= p_lis[i]
    cur_num += p_lis[i + k]
    if max_nums < cur_num:
        max_nums = cur_num
        max_nums_i = i + 1
res = 0
for i in range(max_nums_i, max_nums_i + k):
    res += calc_ex(p_lis[i])
print(res)

Submission status: Runtime Error

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


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

Submission status: Runtime Error

Solution code:

# -*- coding: utf-8 -*-
import numpy as np

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

def main():
    keep_val = 0
    check = 0
    for i in range(n-k+1):
        ss = np_p[i:i+k].sum()
        if keep_val < ss:
            check = i
            keep_val = ss
    print(((np_p[check:check+k]+1)/2).sum())
main()

Submission status: Runtime Error

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

    sums = p[:-2] + p[1:-1] + p[2:]

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

Submission status: Runtime Error

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

import numpy as np

Ps = np.array(Ps)

Exp_each_p = (Ps + 1) /2

sum_Exp = []
for id in range(n - k - 1):
    sum_Exp.append(sum(Exp_each_p[id:(id + k)]))

print(max(sum_Exp))

Submission status: Runtime Error

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

print(p[:k]/k+1)

Submission status: Runtime Error

Solution code:
import numpy as np
n, k = map(int, input().split())
v_list = np.array(list(map(int, input().split())))
merge_list = []
for i in range(k):
  merge_list.append(v_list[i:n+1+i-k])
if k > 1:
  merged_arr = np.vstack(merge_list)
  max_val = merged_arr.sum(axis=1).max()
else:
  max_val = merge_list[0].max()      
print((max_val+k)/2)

Submission status: Runtime Error

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

max_x = 0
idx = 0
x = 0

for i in range(n-k+1):
    x += p[i+k] - p[i]
    if max_x < x:
        max_x = x
        idx = i

ans = (sum(p[i:i+k]) + k) / 2
print(ans)

Submission status: Runtime Error

Solution code:
from copy import copy
N=10
K=4
p=list(map(int, input().split()))
expP = [(1+i)/2 for i in p]
id_H = N-K
id_T = N
minus = sum(expP[:id_H])
minimum = minus
for i in range(id_H):
    minus -= expP[id_H - i -1]
    minus += expP[id_T - i -1]
    if minus < minimum:
        minimum = copy(minus)
ans = sum(expP) - minimum
print(ans)

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[]
max1=0
s=0
c=[]
p=0
for i in range(n):
    s+=a[i]
    c.append(s)

    if i-k>-1:
        b.append(s-c[i-k])


t=max(b)
r=b.index(t)

for i in range(r+1,r+k+1):
    p+=(1/a[i])*(a[i]*(a[i]+1)/2)
print(p)

Submission status: Runtime Error

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

sum_memo = [0]*1001
x_memo = [0] * 1000
x_list = [0]*N

for i in range(1,1001):
    sum_memo[i] = sum_memo[i-1] + i

for i in range(N):
    if x_memo[p[i]] == 0:
        x_memo[p[i]] = sum_memo[p[i]]/p[i]
    x_list[i] = x_memo[p[i]]


ans = 0
tmp = sum(x_list[:K])
for l in range(N-K):
    r = l+K
    tmp = tmp -  x_list[l] + x_list[r]
    ans = max(ans, tmp)
print(ans)

Submission status: Runtime Error

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

def dice_sum(i):
  if i == 1:
    return 1
  else:
    return i + dice_sum(i-1)

ans = 0
for i in range(N-K+1):
  sum, num, ave = 0, 0, 0
  for k in range(K):
    sum = dice_sum(p[i+k])
    num = p[i+k]
    ave += sum/num
  ans = max(ans, ave)

print(ans)

Submission status: Runtime Error

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

max_x = 0
idx = 0
x = 0

for i in range(n-k):
    x += p[i+k] - p[i]
    if max_x < x:
        max_x = x
        idx = i

ans = (sum(p[i:i+k]) + k) / 2
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

sum_k = [0] * N
tmp = 0
for i in range(K):
    tmp += p[i]
sum_k[0] = tmp
max_sum = tmp
candidate = 0
for i in range(len(p)-K):
    sum_k[i+1] = sum_k[i] - p[i] + p[i+K]
    if max_sum < sum_k[i+1]:
        max_sum = sum_k[i+1]
        candidate = i+1


dice = [-1] * 1001

ans = 0
for i in range(candidate, candidate + K):
    tmp = 0
    if dice[p[i]+1] != -1:
        ans += dice[p[i]+1]
        continue
    for j in range(1, p[i]+1):
        tmp += j * (1 / p[i])
    dice[p[i]+1] = tmp
    ans += tmp
print(ans)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p_lis = list(map(int, input().split()))
def calc_ex(num):
    return (num - 1) * 0.5 + 1
cur_num = 0
for i in range(k):
    cur_num += p_lis[i]
max_nums = cur_num
max_nums_i = i
for i in range(len(p_lis) - k):
    cur_num -= p_lis[i]
    cur_num += p_lis[i + k]
    if max_nums < cur_num:
        max_nums = cur_num
        max_nums_i = i + 1
res = 0
for i in range(max_nums_i, max_nums_i + k):
    res += calc_ex(p_lis[i])
print(res)

Submission status: Runtime Error

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


Psoat = sorted(P, reverse=True)

ans = 0
for i in range(K):
    ans = ans+Psoat[i]*0.5+0.5
    

print(ans)

Submission status: Runtime Error

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

    pN_ = []

    ans = 0
    total = 0
    for i, s in enumerate(input().split()):
        total += 1 + int(s)
        pN_.append(total)

        if i == K - 1:
            ans = max(ans, (total / 2)
        elif K <= i:
            ans = max(ans, (total - pN_[i - K]) / 2)

    print(ans)


main()

Submission status: Runtime Error

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

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

pn_max = 0
for i in range(0, n-2):
  pn = 0
  for j in range(k):
  	pn += ps[i+j]
  pn_max = max(pn_max, pn)

print((pn_max+k)/2)

Submission status: Runtime Error

Solution code:
from itertools import accumulate
N,K = map(int,input().split(" "))
p = list(map(int,input().split(" ")))
pp = list(accumulate(p))
ans = 0
for i in range(len(pp)):
    ans = max(ans,(pp[i+K]-pp[i]+K)/2)
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
n,k=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
p=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
max = 0
final = []
#最大のリストを選定
for i in range(0,n-k):
    ck = sum(p[i:i+k])
    if ck > max:
        final = p[i:i+k]
        max = ck

#計算
print((ck+k)/2.0)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p_i = input().split()
answer = 0
for x in range(n):
    if x <= k - 1:
        sum = 0
        for y in range(k):
            sum += int(p_i[x + y])
        answer = max(answer, sum)
print((answer + k) / 2)

Submission status: Runtime Error

Solution code:
from itertools import accumulate
N,K = map(int,input().split(" "))
p = list(map(int,input().split(" ")))
pp = list(accumulate(p))
ans = 0
for i in range(len(pp)//2+1):
    ans = max(ans,(pp[i+K]-pp[i]+K)/2,(pp[-1-i]-pp[-1-i-K]+K)/2)
print(ans)

Submission status: Runtime Error

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

sum_k = [0] * N
tmp = 0
for i in range(K):
    tmp += p[i]
sum_k[0] = tmp
max_sum = tmp
candidate = 0
for i in range(len(p)-K):
    sum_k[i+1] = sum_k[i] - p[i] + p[i+K]
    if max_sum < sum_k[i+1]:
        max_sum = sum_k[i+1]
        candidate = i+1


dice = [0] * 1001

ans = 0
for i in range(candidate, candidate + K):
    tmp = 0
    if dice[p[i]+1] != 0:
        ans += dice[p[i]+1]
        continue
    for j in range(1, p[i]+1):
        tmp += j * (1 / p[i])
    dice[p[i]+1] = tmp
    ans += tmp
print(ans)

Submission status: Runtime Error

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

P = []+p
P = list(accumulate(P))

ans = []
for i in range(n-k):
    ans.append(P[i+k]-P[i])

print((max(ans)+k)/2)

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split()))
i=list(map(int,input().split()))
l=[0]*(n-k)
for j in range(n-k):
  l[j]=i[j+k]-i[j]
place=0
plus=0
for j in range(n-k):
  plus=plus+l[j]
  if plus>0:
    place=j+1
    plus=0
a=0
for j in range(k):
  a+=(i[j+place]+1)//2
print(a)

Submission status: Runtime Error

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

for i in range(N-K):
    f = f + p[i+K] - p[i]
    a[i] = f
    
num = 0

for i in range(1,N-K):
    if a[i] > a[i-1]:
        num = i
ans = 0

for i in range(num+1,num+K+1):
    ans += (p[i]+1)/2

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
n, k = map(int, input().split())
v_list = np.array(list(map(int, input().split())))
merge_list = []
for i in range(k):
  merge_list.append(v_list[i:n+1+i-k])
merged_arr = np.vstack(merge_list)
print((merged_arr.sum(axis=1).max()+k)/2)

Submission status: Runtime Error

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

ans=[]
for i in range(n-k):
  ans.append(sum(p[i:k+i]))
index=ans.index(max(ans))
total=0
for i in p[index:index+k]:
  total+=(i*(i+1))/(2*i)
print(total)

Submission status: Runtime Error

Solution code:
import numpy as np


def expected_value(x):
    return 0.5*(x+1)

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

candidates = np.array(map(int, input().split()))
s = np.convolve(0.5*(candidates+1), np.ones(m), mode='valid')
print(s.max())