結果

問題 No.1007 コイン集め
ユーザー titiatitia
提出日時 2020-03-06 21:45:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 574 bytes
コンパイル時間 329 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 21,876 KB
最終ジャッジ日時 2024-04-22 06:07:09
合計ジャッジ時間 2,020 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 26 ms
10,496 KB
testcase_02 AC 26 ms
10,496 KB
testcase_03 AC 25 ms
10,496 KB
testcase_04 AC 25 ms
10,624 KB
testcase_05 AC 26 ms
10,752 KB
testcase_06 AC 25 ms
10,624 KB
testcase_07 AC 27 ms
10,496 KB
testcase_08 WA -
testcase_09 RE -
testcase_10 AC 27 ms
10,624 KB
testcase_11 RE -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 46 ms
12,660 KB
testcase_16 AC 45 ms
12,788 KB
testcase_17 AC 45 ms
12,916 KB
testcase_18 WA -
testcase_19 AC 57 ms
21,568 KB
testcase_20 RE -
testcase_21 AC 73 ms
21,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
elif A[K]==1:
    A1=0
    for i in range(K+1,N-1):
        A1+=A[i]
        if A[i]<=1:
            break
    A2=0
    for i in range(K-1,-1,-1):
        A0+=A[i]
        if A[i]<=1:
            break
    print(max(A1,A2)+1)
else:
    ANS=A[K]
    for i in range(K+1,N-1):
        ANS+=A[i]
        if A[i]<=1:
            break
    for i in range(K-1,-1,-1):
        ANS+=A[i]
        if A[i]<=1:
            break
    print(ANS)
    
0