結果

問題 No.1007 コイン集め
ユーザー 👑 timitimi
提出日時 2020-10-29 15:03:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 95 ms / 1,500 ms
コード長 475 bytes
コンパイル時間 137 ms
コンパイル使用メモリ 10,832 KB
実行使用メモリ 19,276 KB
最終ジャッジ日時 2023-09-29 03:59:38
合計ジャッジ時間 3,027 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,856 KB
testcase_01 AC 16 ms
8,124 KB
testcase_02 AC 16 ms
7,768 KB
testcase_03 AC 15 ms
8,120 KB
testcase_04 AC 16 ms
7,844 KB
testcase_05 AC 16 ms
7,912 KB
testcase_06 AC 16 ms
7,900 KB
testcase_07 AC 16 ms
7,932 KB
testcase_08 AC 15 ms
7,856 KB
testcase_09 AC 16 ms
7,804 KB
testcase_10 AC 16 ms
7,836 KB
testcase_11 AC 16 ms
7,796 KB
testcase_12 AC 94 ms
19,232 KB
testcase_13 AC 93 ms
19,276 KB
testcase_14 AC 95 ms
19,260 KB
testcase_15 AC 34 ms
10,712 KB
testcase_16 AC 33 ms
10,680 KB
testcase_17 AC 34 ms
10,676 KB
testcase_18 AC 90 ms
18,912 KB
testcase_19 AC 48 ms
18,980 KB
testcase_20 AC 90 ms
19,004 KB
testcase_21 AC 68 ms
18,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int, input().split())
A=list(map(int, input().split()))
lcnt,rcnt=0,0
K-=1 
if A[K]==0:
    print(0)
    exit()

for i in range(K):
    if A[K-1-i]==0:
        break
    elif A[K-1-i]==1:
        lcnt+=1 
        break
    else:
        lcnt+=A[K-1-i]
for i in range(N-K-1):
    if A[K+1+i]==0:
        break
    elif A[K+1+i]==1:
        rcnt+=1 
        break
    else:
        rcnt+=A[K+1+i] 
if A[K]==1:
    print(max(rcnt,lcnt)+1)
else:
    print(rcnt+lcnt+A[K])
0