結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,752 KB
testcase_01 AC 27 ms
10,752 KB
testcase_02 AC 28 ms
10,880 KB
testcase_03 AC 28 ms
10,624 KB
testcase_04 AC 31 ms
10,624 KB
testcase_05 AC 30 ms
10,624 KB
testcase_06 AC 31 ms
10,624 KB
testcase_07 AC 29 ms
10,624 KB
testcase_08 AC 29 ms
10,752 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 126 ms
21,836 KB
testcase_13 AC 122 ms
21,712 KB
testcase_14 AC 123 ms
21,712 KB
testcase_15 AC 56 ms
13,112 KB
testcase_16 AC 57 ms
13,112 KB
testcase_17 AC 56 ms
13,116 KB
testcase_18 AC 116 ms
21,676 KB
testcase_19 AC 71 ms
21,680 KB
testcase_20 WA -
testcase_21 AC 95 ms
21,680 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
  print(ans+ans_l+ans_r)
0