結果

問題 No.1007 コイン集め
ユーザー syunsukesyunsuke
提出日時 2020-09-14 23:17:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 99 ms / 1,500 ms
コード長 652 bytes
コンパイル時間 492 ms
コンパイル使用メモリ 87,104 KB
実行使用メモリ 94,248 KB
最終ジャッジ日時 2023-09-04 00:52:14
合計ジャッジ時間 3,363 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,472 KB
testcase_01 AC 69 ms
71,168 KB
testcase_02 AC 69 ms
71,320 KB
testcase_03 AC 69 ms
71,224 KB
testcase_04 AC 71 ms
71,364 KB
testcase_05 AC 71 ms
71,524 KB
testcase_06 AC 71 ms
71,308 KB
testcase_07 AC 71 ms
71,272 KB
testcase_08 AC 69 ms
71,400 KB
testcase_09 AC 71 ms
71,316 KB
testcase_10 AC 71 ms
71,420 KB
testcase_11 AC 71 ms
71,428 KB
testcase_12 AC 98 ms
93,580 KB
testcase_13 AC 99 ms
93,684 KB
testcase_14 AC 99 ms
93,892 KB
testcase_15 AC 87 ms
90,756 KB
testcase_16 AC 88 ms
90,700 KB
testcase_17 AC 88 ms
90,744 KB
testcase_18 AC 96 ms
93,848 KB
testcase_19 AC 95 ms
93,328 KB
testcase_20 AC 97 ms
93,984 KB
testcase_21 AC 96 ms
94,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int,input().split())
L=[0]+list(map(int,input().split()))+[0]

if L[K]==0:
    print(0)
    exit()
else:
    right=L[K]
    for r in range(K+1,10**9):
        if L[r]>1:
            right+=L[r]
        if L[r]==1:
            right+=1
            break
        if L[r]==0:
            break
    left=L[K]
    for l in range(1,10**9):
        if L[K-l]>1:
            left+=L[K-l]
        if L[K-l]==1:
            left+=1
            break
        if L[K-l]==0:
            break
    if L[K]==1:
        print(max(left,right))
        #print(left,right)
        #print(L)
    else:
        print(left+right-L[K])
        #print(left,right)
    
0