結果

問題 No.1007 コイン集め
ユーザー nebukuro09nebukuro09
提出日時 2020-03-06 21:51:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 92 ms / 1,500 ms
コード長 356 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 21,928 KB
最終ジャッジ日時 2024-04-22 07:08:44
合計ジャッジ時間 2,119 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 AC 30 ms
10,752 KB
testcase_02 AC 30 ms
10,752 KB
testcase_03 AC 30 ms
10,880 KB
testcase_04 AC 30 ms
10,624 KB
testcase_05 AC 30 ms
10,752 KB
testcase_06 AC 31 ms
10,752 KB
testcase_07 AC 30 ms
10,752 KB
testcase_08 AC 31 ms
10,880 KB
testcase_09 AC 31 ms
10,752 KB
testcase_10 AC 30 ms
10,752 KB
testcase_11 AC 30 ms
10,752 KB
testcase_12 AC 92 ms
21,688 KB
testcase_13 AC 90 ms
21,928 KB
testcase_14 AC 91 ms
21,816 KB
testcase_15 AC 51 ms
12,960 KB
testcase_16 AC 51 ms
13,084 KB
testcase_17 AC 51 ms
12,960 KB
testcase_18 AC 91 ms
21,532 KB
testcase_19 AC 68 ms
21,664 KB
testcase_20 AC 92 ms
21,664 KB
testcase_21 AC 79 ms
21,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
a = list(map(int, input().split()))
k -= 1

if a[k] == 0:
    print(0)
    exit(0)

left = 0
right = 0

for i in range(k-1, -1, -1):
    left += a[i]
    if a[i] <= 1:
        break

for i in range(k+1, n):
    right += a[i]
    if a[i] <= 1:
        break

print(max(left, right) + 1 if a[k] == 1 else left + right + a[k])
0