結果

問題 No.1007 コイン集め
ユーザー 👑 rin204rin204
提出日時 2020-08-13 12:56:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 467 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 21,800 KB
最終ジャッジ日時 2024-04-18 01:28:49
合計ジャッジ時間 2,202 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,624 KB
testcase_01 AC 31 ms
10,752 KB
testcase_02 AC 32 ms
10,752 KB
testcase_03 AC 32 ms
10,752 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 30 ms
10,752 KB
testcase_08 AC 32 ms
10,624 KB
testcase_09 AC 31 ms
10,880 KB
testcase_10 AC 31 ms
10,624 KB
testcase_11 AC 31 ms
10,752 KB
testcase_12 AC 86 ms
21,648 KB
testcase_13 AC 86 ms
21,712 KB
testcase_14 AC 86 ms
21,732 KB
testcase_15 AC 52 ms
13,224 KB
testcase_16 AC 52 ms
13,092 KB
testcase_17 AC 52 ms
13,096 KB
testcase_18 RE -
testcase_19 AC 69 ms
21,676 KB
testcase_20 AC 90 ms
21,544 KB
testcase_21 AC 80 ms
21,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
alst = list(map(int, input().split()))
k -= 1
if alst[k] == 0:
    print(0)
    exit()

pos_l = k - 1
while 1:
    if alst[pos_l] < 2 or pos_l == 0:
        break
    pos_l -= 1

pos_r = k + 1
while 1:
    if alst[pos_r] < 2 or pos_r == n - 1:
        break
    pos_r += 1
pos_r += 1

l_sum = sum(alst[pos_l:k])
r_sum = sum(alst[k + 1:pos_r])

if alst[k] == 1:
    print(max(l_sum, r_sum) + 1)
else:
    print(l_sum + r_sum + alst[k])
0