結果

問題 No.1007 コイン集め
ユーザー OhnumaOhnuma
提出日時 2020-04-05 20:54:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 440 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 10,968 KB
実行使用メモリ 19,200 KB
最終ジャッジ日時 2023-09-17 05:54:47
合計ジャッジ時間 1,852 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,792 KB
testcase_01 AC 15 ms
7,816 KB
testcase_02 AC 16 ms
7,756 KB
testcase_03 AC 16 ms
7,772 KB
testcase_04 AC 15 ms
7,812 KB
testcase_05 AC 15 ms
7,972 KB
testcase_06 AC 15 ms
7,764 KB
testcase_07 AC 15 ms
7,976 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 16 ms
7,944 KB
testcase_11 AC 15 ms
7,940 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 69 ms
19,000 KB
testcase_19 AC 48 ms
18,840 KB
testcase_20 AC 68 ms
18,844 KB
testcase_21 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k = map(int,input().split())
A = list(map(int,input().split()))
k -= 1
if A[k]==0:
    print(0)
else:
    
    l,r = k+1, k-1
    for r in range(k+1, n):
        if A[r]==0 or A[r]%2!=0:
            break
    
    for l in range(k-1, 0, -1):
        if A[l]==0 or A[l]%2!=0:
            break
    
    sr = sum(A[k+1:r+1])
    sl = sum(A[l:k])
    
    if A[k]==1:
        print(A[k] + max(sr, sl))
    else:
        print(A[k] + sr + sl)
0