結果

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

テストケース

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

ソースコード

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 alst[pos_l] > 1 and pos_l != -1:
    pos_l -= 1
    if pos_l == -1:
        break

pos_r = k
while alst[pos_r] > 1 and pos_r != n:
    pos_r += 1
    if pos_r == n:
        break
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