結果

問題 No.1007 コイン集め
ユーザー brthyyjpbrthyyjp
提出日時 2020-03-06 23:57:47
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 553 bytes
コンパイル時間 443 ms
コンパイル使用メモリ 82,320 KB
実行使用メモリ 94,344 KB
最終ジャッジ日時 2024-04-22 10:57:47
合計ジャッジ時間 2,643 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,928 KB
testcase_01 AC 38 ms
52,216 KB
testcase_02 AC 39 ms
52,424 KB
testcase_03 AC 42 ms
52,088 KB
testcase_04 RE -
testcase_05 AC 40 ms
53,064 KB
testcase_06 AC 39 ms
52,240 KB
testcase_07 AC 38 ms
51,880 KB
testcase_08 AC 39 ms
52,564 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 71 ms
88,236 KB
testcase_13 AC 70 ms
89,472 KB
testcase_14 AC 69 ms
87,924 KB
testcase_15 AC 67 ms
84,636 KB
testcase_16 AC 67 ms
83,212 KB
testcase_17 AC 68 ms
84,564 KB
testcase_18 AC 69 ms
88,888 KB
testcase_19 AC 63 ms
84,036 KB
testcase_20 RE -
testcase_21 AC 70 ms
89,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
A = list(map(int, input().split()))

if A[k-1] == 0:
    print(0)
    exit()

A = [0] + A + [0]
#print(A)

for i in range(k):
    if A[i] == 0:
        p = i
        q = 0
    elif A[i] == 1:
        p = i
        q = 1

for i in reversed(range(k+1, n+2)):
    if A[i] == 0:
        r = i
        s = 0
    elif A[i] == 1:
        r = i
        s = 1

if A[k] >= 2:
    #print(p, q, r, s)
    ans = sum(A[p:k])+A[k]+sum(A[k+1:r+1])
    print(ans)
else:
    ans += max(sum(A[p:k]), sum(A[k+1:r+1])) + A[k]
    print(ans)
0