結果

問題 No.1007 コイン集め
ユーザー syunsuke
提出日時 2020-09-14 23:13:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 597 bytes
コンパイル時間 361 ms
コンパイル使用メモリ 82,480 KB
実行使用メモリ 94,624 KB
最終ジャッジ日時 2024-06-22 00:59:55
合計ジャッジ時間 2,304 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9 WA * 8 RE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int,input().split())
L=[0]+list(map(int,input().split()))+[0]

if L[K]==0:
    print(0)
    exit()
else:
    right=0
    for r in range(K,10**9):
        if L[r]>1:
            right+=L[r]
        if L[r]==1:
            right+=1
            break
        if L[r]==0:
            break
    left=0
    for l in range(10**9):
        if L[K-l]>1:
            left+=L[K+l]
        if L[K-l]==1:
            left+=1
            break
        if L[K-l]==0:
            break
    if L[K]==1:
        print(max(left,right))
    else:
        print(left+right-L[K])
        #print(left,right)
    
0