結果

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

ソースコード

diff #

#clean
N,M=(int(i) for i in input().split())
s=0
D=[]
nd=0
for i in range(M):
    D.append(int(input()))
    if D[i]>=0 and nd==0:
        s=i
#座標が0以上で最も原点に近い所をs
        nd=1
i=0
mi=0
if s+N-1 <M:
    mi=D[s+N-1]
    r=0
    pl=D[s+N-1]
    mp=s+N-1
  #  print (s)
else:
    r=s+N-M
    if s-r>=0:
        mp=M-1
        pl=D[-1]
        nus=-1*D[s-r]
        if nus<pl:
            db=nus
        else:
            db=pl
        mi=pl+nus+db
    #    print (mi)
r+=1
mp-=1
while mp>=s and s-r>=0:
    nus=-1*D[s-r]
 #   print (nus)
    pl=D[mp]
 #   print (mp)
    if nus<pl:
        db=nus
    else:
        db=pl
    m1=pl+nus+db
  #  print (m1)
    if m1<mi:
        mi=m1
    r+=1
    mp-=1
if s-N>=0:
    m1=-1*D[s-N]
    if m1<mi:
        mi=m1
print(mi)
0