結果

問題 No.1007 コイン集め
ユーザー hirakuhiraku
提出日時 2020-04-08 05:32:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 75 ms / 1,500 ms
コード長 391 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 10,856 KB
実行使用メモリ 18,968 KB
最終ジャッジ日時 2023-09-23 04:14:59
合計ジャッジ時間 2,325 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,788 KB
testcase_01 AC 16 ms
7,812 KB
testcase_02 AC 16 ms
7,784 KB
testcase_03 AC 16 ms
7,824 KB
testcase_04 AC 17 ms
7,824 KB
testcase_05 AC 17 ms
7,824 KB
testcase_06 AC 16 ms
7,856 KB
testcase_07 AC 16 ms
7,888 KB
testcase_08 AC 16 ms
7,908 KB
testcase_09 AC 17 ms
7,736 KB
testcase_10 AC 16 ms
7,864 KB
testcase_11 AC 17 ms
7,816 KB
testcase_12 AC 72 ms
18,968 KB
testcase_13 AC 72 ms
18,852 KB
testcase_14 AC 71 ms
18,840 KB
testcase_15 AC 34 ms
10,576 KB
testcase_16 AC 34 ms
10,508 KB
testcase_17 AC 35 ms
10,572 KB
testcase_18 AC 75 ms
18,856 KB
testcase_19 AC 74 ms
18,924 KB
testcase_20 AC 72 ms
18,852 KB
testcase_21 AC 62 ms
18,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

ans = 0

l = 0
if k - 2 >= 0:
  for i in range(k - 2, -1, -1):
    l += A[i]
    if A[i] <= 1:
      break

r = 0
if k < n:
  for i in range(k, n):
    r += A[i]
    if A[i] <= 1:
      break
      
if A[k - 1] == 0:
  ans = 0      
elif A[k - 1] == 1:
  ans = A[k -1] + max(l, r)
else:
  ans = A[k -1] + l + r
print(ans)
0