結果

問題 No.1007 コイン集め
ユーザー tamatotamato
提出日時 2020-03-06 21:54:46
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 450 bytes
コンパイル時間 226 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 82,560 KB
最終ジャッジ日時 2024-04-22 07:25:15
合計ジャッジ時間 2,359 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
51,840 KB
testcase_01 AC 40 ms
51,712 KB
testcase_02 AC 40 ms
51,712 KB
testcase_03 AC 41 ms
51,840 KB
testcase_04 AC 41 ms
51,584 KB
testcase_05 AC 42 ms
51,840 KB
testcase_06 AC 41 ms
51,584 KB
testcase_07 AC 41 ms
51,712 KB
testcase_08 AC 43 ms
51,968 KB
testcase_09 WA -
testcase_10 AC 42 ms
51,840 KB
testcase_11 WA -
testcase_12 AC 73 ms
81,664 KB
testcase_13 AC 72 ms
81,536 KB
testcase_14 AC 72 ms
82,304 KB
testcase_15 AC 63 ms
75,904 KB
testcase_16 AC 62 ms
76,416 KB
testcase_17 AC 61 ms
75,776 KB
testcase_18 AC 71 ms
82,048 KB
testcase_19 AC 70 ms
81,408 KB
testcase_20 WA -
testcase_21 AC 75 ms
82,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    input = sys.stdin.readline

    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    K -= 1
    if A[K] == 0:
        print(0)
        exit()

    ans = A[K]
    for k in range(K+1, N):
        ans += A[k]
        if A[k] <= 1:
            break
    for k in range(K-1, -1, -1):
        ans += A[k]
        if A[k] <= 1:
            break
    print(ans)


if __name__ == '__main__':
    main()
0