結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,752 KB
testcase_01 AC 29 ms
10,752 KB
testcase_02 AC 30 ms
10,752 KB
testcase_03 AC 30 ms
10,752 KB
testcase_04 WA -
testcase_05 AC 30 ms
10,752 KB
testcase_06 AC 30 ms
10,752 KB
testcase_07 AC 30 ms
10,624 KB
testcase_08 AC 29 ms
10,752 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 93 ms
21,588 KB
testcase_13 AC 94 ms
21,720 KB
testcase_14 AC 93 ms
21,716 KB
testcase_15 AC 51 ms
13,160 KB
testcase_16 AC 50 ms
13,036 KB
testcase_17 AC 50 ms
13,040 KB
testcase_18 AC 97 ms
21,604 KB
testcase_19 AC 66 ms
21,736 KB
testcase_20 WA -
testcase_21 AC 80 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(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