結果

問題 No.1007 コイン集め
ユーザー NagisaNagisa
提出日時 2020-03-06 22:28:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 972 bytes
コンパイル時間 186 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 21,736 KB
最終ジャッジ日時 2024-04-22 08:51:34
合計ジャッジ時間 2,242 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,624 KB
testcase_01 AC 28 ms
10,752 KB
testcase_02 AC 28 ms
10,752 KB
testcase_03 AC 29 ms
10,624 KB
testcase_04 WA -
testcase_05 AC 26 ms
10,752 KB
testcase_06 AC 26 ms
10,880 KB
testcase_07 AC 26 ms
10,752 KB
testcase_08 AC 26 ms
10,624 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 87 ms
21,460 KB
testcase_13 AC 86 ms
21,468 KB
testcase_14 AC 88 ms
21,592 KB
testcase_15 AC 45 ms
12,912 KB
testcase_16 AC 44 ms
13,036 KB
testcase_17 AC 47 ms
12,904 KB
testcase_18 AC 88 ms
21,480 KB
testcase_19 AC 59 ms
21,736 KB
testcase_20 WA -
testcase_21 AC 73 ms
21,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int,input().split())
A = list(map(int,input().split()))
if A[K-1] == 0:
    print(0)
elif A[K-1] == 1:
    now = K-2
    l = 0
    while now >= 0:
        if A[now] >= 2:
            l += A[now]
        elif A[now] == 1:
            l += 1
            break
        else:
            break
        now -= 1
    r = 0
    now = K
    while now < N:
        if A[now] >= 2:
            r += A[now]
        elif A[now] == 1:
            r += 1
            break
        else:
            break
        now += 1
    print(max(l,r))
else:
    now = K-2
    l = 0
    while now >= 0:
        if A[now] >= 2:
            l += A[now]
        elif A[now] == 1:
            l += 1
            break
        else:
            break
        now -= 1
    r = 0
    now = K
    while now < N:
        if A[now] >= 2:
            r += A[now]
        elif A[now] == 1:
            r += 1
            break
        else:
            break
        now += 1
    print(l+r+A[K-1])
0