結果

問題 No.1007 コイン集め
ユーザー takakintakakin
提出日時 2020-05-24 23:32:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 539 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 21,852 KB
最終ジャッジ日時 2024-04-20 16:17:01
合計ジャッジ時間 2,680 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,624 KB
testcase_01 AC 29 ms
10,752 KB
testcase_02 AC 29 ms
10,624 KB
testcase_03 AC 30 ms
10,624 KB
testcase_04 AC 29 ms
10,624 KB
testcase_05 AC 29 ms
10,624 KB
testcase_06 AC 29 ms
10,624 KB
testcase_07 AC 30 ms
10,752 KB
testcase_08 AC 29 ms
10,624 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 125 ms
21,724 KB
testcase_13 AC 129 ms
21,852 KB
testcase_14 AC 130 ms
21,852 KB
testcase_15 AC 58 ms
13,140 KB
testcase_16 AC 57 ms
13,140 KB
testcase_17 AC 57 ms
13,140 KB
testcase_18 AC 123 ms
21,560 KB
testcase_19 AC 74 ms
21,560 KB
testcase_20 WA -
testcase_21 AC 99 ms
21,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n,k=map(int,input().split())
A=[int(i) for i in input().split()]
if A[k-1]<=1:
  print(A[k-1])
else:
  ans=A[k-1]
  ans_l,ans_r=0,0
  l,r=1,1
  while k-1-l>=0:
    if A[k-1-l]>=2:
      ans_l+=A[k-1-l]
      l+=1
      continue
    else:
      ans_l+=A[k-1-l]
      break
  while k-1+r<n:
    if A[k-1+r]>=2:
      ans_r+=A[k-1+r]
      r+=1
      continue
    else:
      ans_r+=A[k-1+r]
      break
  if A[k-1]==1:
    print(ans+max(ans_l,ans_r))
  else:
    print(ans+ans_l+ans_r)
0