結果

問題 No.370 道路の掃除
ユーザー rocoderrocoder
提出日時 2017-07-25 16:12:58
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 576 bytes
コンパイル時間 433 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-10-09 17:07:25
合計ジャッジ時間 2,748 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other RE * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#clean
N,M=(int(i) for i in input().split())
s=0
for i in range(N):
    D.append(int(input()))
    if D[i]>0 and s==0:
        s=i
i=0
mi=0
if s+M-1 <len(D):
    mi=D[s+M-1]
    r=0
    pl=D[s+M-1]
    mp=s+M
else:
    r=s+M-len(D)+1
    if s-r>=0:
        mp=len(D)-1
        pl=D[-1]
        nus=D[s-r]*-1
        if nus<pl:
            db=nus
        else:
            db=pl
        mi=pl+nus+db
r+=1
while s-r>=0:
    nus=-1*D[s-r]
    mp-=1
    pl=D[mp]
    if nus<pl:
        db=nus
    else:
        db=pl
    m1=pl+nus+db
    if m1<mi:
        mi=m1
    r+=1
print(mi)
0