結果

問題 No.1007 コイン集め
ユーザー roarisroaris
提出日時 2020-03-13 12:49:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 98 ms / 1,500 ms
コード長 407 bytes
コンパイル時間 783 ms
コンパイル使用メモリ 87,192 KB
実行使用メモリ 91,340 KB
最終ジャッジ日時 2023-08-14 04:17:39
合計ジャッジ時間 4,186 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,340 KB
testcase_01 AC 70 ms
71,488 KB
testcase_02 AC 70 ms
71,124 KB
testcase_03 AC 71 ms
71,412 KB
testcase_04 AC 74 ms
71,532 KB
testcase_05 AC 73 ms
71,356 KB
testcase_06 AC 72 ms
71,548 KB
testcase_07 AC 71 ms
71,560 KB
testcase_08 AC 70 ms
71,320 KB
testcase_09 AC 71 ms
71,220 KB
testcase_10 AC 71 ms
71,316 KB
testcase_11 AC 72 ms
71,456 KB
testcase_12 AC 96 ms
91,260 KB
testcase_13 AC 97 ms
91,076 KB
testcase_14 AC 98 ms
91,084 KB
testcase_15 AC 90 ms
88,332 KB
testcase_16 AC 87 ms
88,220 KB
testcase_17 AC 89 ms
88,228 KB
testcase_18 AC 97 ms
91,320 KB
testcase_19 AC 95 ms
90,432 KB
testcase_20 AC 97 ms
91,340 KB
testcase_21 AC 96 ms
90,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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

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

for i in range(K-1, -1, -1):
    if A[i]<=1:
        l = i
        break
else:
    l = 0

if A[K]==0:
    print(0)
elif A[K]==1:
    print(max(sum(A[l:K+1]), sum(A[K:r+1])))
else:
    print(sum(A[l:r+1]))
0