結果

問題 No.1007 コイン集め
ユーザー toyuzuko
提出日時 2020-03-11 23:38:52
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 98 ms / 1,500 ms
コード長 385 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 21,692 KB
最終ジャッジ日時 2024-11-16 03:58:57
合計ジャッジ時間 2,088 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

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

left = 0
right = 0

for i in range(K - 1):
    left += A[K - 2 - i]
    if A[K - 2 - i] <= 1:
        break

for i in range(N - K):
    right += A[K + i]
    if A[K + i] <= 1:
        break

if A[K - 1] == 0:
    print(0)

elif A[K - 1] == 1:
    print(max(left,right) + 1)

else:
    print(left + A[K - 1] + right)
0