結果

問題 No.1007 コイン集め
ユーザー 👑 H20H20
提出日時 2021-01-27 09:55:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 102 ms / 1,500 ms
コード長 436 bytes
コンパイル時間 616 ms
コンパイル使用メモリ 87,220 KB
実行使用メモリ 92,516 KB
最終ジャッジ日時 2023-09-06 14:16:07
合計ジャッジ時間 3,430 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,356 KB
testcase_01 AC 73 ms
71,408 KB
testcase_02 AC 72 ms
71,404 KB
testcase_03 AC 76 ms
71,384 KB
testcase_04 AC 72 ms
71,320 KB
testcase_05 AC 73 ms
71,384 KB
testcase_06 AC 74 ms
71,424 KB
testcase_07 AC 72 ms
71,328 KB
testcase_08 AC 73 ms
71,336 KB
testcase_09 AC 72 ms
71,660 KB
testcase_10 AC 72 ms
71,528 KB
testcase_11 AC 73 ms
71,376 KB
testcase_12 AC 100 ms
92,108 KB
testcase_13 AC 100 ms
92,132 KB
testcase_14 AC 102 ms
92,284 KB
testcase_15 AC 91 ms
88,472 KB
testcase_16 AC 89 ms
88,440 KB
testcase_17 AC 88 ms
88,472 KB
testcase_18 AC 99 ms
92,516 KB
testcase_19 AC 97 ms
91,040 KB
testcase_20 AC 101 ms
92,388 KB
testcase_21 AC 99 ms
91,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = map(int, input().split())
A = list(map(int, input().split())) 
r=K-1
l=K-1
if A[K-1]>=2:
    while l>=1 and A[l]>=2 and A[l-1]>=1:
        l-=1
    while r<N-1 and A[r]>=2 and A[r+1]>=1:
        r+=1
    print(sum(A[l:r+1]))
elif A[K-1]==0:
    print(0)
else:
    A[K-1]+=1
    while l>=1 and A[l]>=2 and A[l-1]>=1:
        l-=1
    while r<N-1 and A[r]>=2 and A[r+1]>=1:
        r+=1
    print(max(sum(A[l:K]),sum(A[K-1:r+1]))-1)
0