結果

問題 No.1007 コイン集め
ユーザー O2MTO2MT
提出日時 2021-06-09 13:49:25
言語 PyPy3
(7.3.13)
結果
RE  
実行時間 -
コード長 403 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 86,840 KB
実行使用メモリ 99,172 KB
最終ジャッジ日時 2023-08-18 18:22:55
合計ジャッジ時間 4,131 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
71,204 KB
testcase_01 AC 65 ms
71,216 KB
testcase_02 AC 64 ms
71,432 KB
testcase_03 AC 65 ms
71,000 KB
testcase_04 AC 65 ms
71,428 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 66 ms
71,380 KB
testcase_08 AC 66 ms
71,432 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 WA -
testcase_16 AC 84 ms
95,292 KB
testcase_17 AC 82 ms
95,228 KB
testcase_18 RE -
testcase_19 AC 82 ms
91,532 KB
testcase_20 WA -
testcase_21 AC 92 ms
98,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import accumulate
N,K = map(int,input().split())
N += 1
A = [0]+list(map(int,input().split()))
if A[K] == 0:
  print(0)
  exit()
l,r = 1,N
for i in range(K,N):
  if A[i] == 0 or A[i] == 1:
    r = i
    break
for i in range(K,-1,-1):
  if A[i] == 1:
    l = i
    break
AC = list(accumulate(A))
if A[K] == 1:
  ans = max(AC[r]-AC[K-1],AC[K]-AC[l-1])
else:
  ans = AC[r]-AC[l-1]
print(ans)
0