結果

問題 No.1007 コイン集め
ユーザー titiatitia
提出日時 2020-03-06 21:43:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 563 bytes
コンパイル時間 333 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 21,740 KB
最終ジャッジ日時 2024-04-22 05:46:10
合計ジャッジ時間 2,144 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,624 KB
testcase_01 AC 30 ms
10,496 KB
testcase_02 AC 28 ms
10,624 KB
testcase_03 AC 27 ms
10,752 KB
testcase_04 AC 27 ms
10,624 KB
testcase_05 AC 26 ms
10,496 KB
testcase_06 AC 25 ms
10,624 KB
testcase_07 AC 26 ms
10,624 KB
testcase_08 AC 26 ms
10,496 KB
testcase_09 RE -
testcase_10 AC 24 ms
10,496 KB
testcase_11 RE -
testcase_12 AC 81 ms
21,508 KB
testcase_13 AC 81 ms
21,612 KB
testcase_14 AC 82 ms
21,740 KB
testcase_15 AC 44 ms
12,904 KB
testcase_16 AC 46 ms
12,780 KB
testcase_17 AC 44 ms
12,908 KB
testcase_18 AC 82 ms
21,436 KB
testcase_19 AC 59 ms
21,412 KB
testcase_20 RE -
testcase_21 AC 69 ms
21,436 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):
        A1+=A[i]
        if A[i]<=1:
            break
    A2=0
    for i in range(K-1,-1,-1):
        A0+=A[i]
        if A[i]<0:
            break
    print(max(A1,A2)+1)
else:
    ANS=A[K]
    for i in range(K+1,N):
        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