結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,752 KB
testcase_01 AC 32 ms
10,752 KB
testcase_02 AC 32 ms
10,752 KB
testcase_03 AC 32 ms
10,752 KB
testcase_04 AC 32 ms
10,880 KB
testcase_05 AC 32 ms
10,752 KB
testcase_06 AC 31 ms
10,752 KB
testcase_07 AC 33 ms
10,880 KB
testcase_08 AC 31 ms
10,752 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 86 ms
21,824 KB
testcase_13 AC 87 ms
21,960 KB
testcase_14 AC 88 ms
21,704 KB
testcase_15 AC 53 ms
13,092 KB
testcase_16 AC 52 ms
13,224 KB
testcase_17 AC 53 ms
12,976 KB
testcase_18 AC 91 ms
21,672 KB
testcase_19 AC 68 ms
21,672 KB
testcase_20 WA -
testcase_21 AC 78 ms
21,668 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
while 1:
    if alst[pos_l] < 2 or pos_l == 0:
        break
    pos_l -= 1

pos_r = k
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