結果

問題 No.1007 コイン集め
ユーザー O2MTO2MT
提出日時 2021-06-09 13:58:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 466 bytes
コンパイル時間 549 ms
コンパイル使用メモリ 87,272 KB
実行使用メモリ 98,824 KB
最終ジャッジ日時 2023-08-18 18:32:23
合計ジャッジ時間 3,555 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
71,404 KB
testcase_01 AC 58 ms
71,144 KB
testcase_02 AC 60 ms
71,568 KB
testcase_03 AC 61 ms
71,184 KB
testcase_04 AC 60 ms
71,248 KB
testcase_05 AC 60 ms
71,468 KB
testcase_06 AC 60 ms
71,576 KB
testcase_07 AC 58 ms
71,400 KB
testcase_08 AC 62 ms
71,424 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 95 ms
98,272 KB
testcase_13 AC 90 ms
98,360 KB
testcase_14 AC 90 ms
98,292 KB
testcase_15 AC 84 ms
95,516 KB
testcase_16 AC 80 ms
95,572 KB
testcase_17 AC 79 ms
95,568 KB
testcase_18 AC 88 ms
98,824 KB
testcase_19 AC 80 ms
92,264 KB
testcase_20 WA -
testcase_21 AC 88 ms
98,612 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()
if N == 2:
  print(A[-1])
  exit()
l,r = 1,N-1
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 or (i != 0 and A[i] == 0):
    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