結果

問題 No.1007 コイン集め
ユーザー kozykozy
提出日時 2021-05-08 23:55:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 90 ms / 1,500 ms
コード長 396 bytes
コンパイル時間 134 ms
コンパイル使用メモリ 11,828 KB
実行使用メモリ 21,096 KB
最終ジャッジ日時 2023-10-17 09:03:11
合計ジャッジ時間 2,332 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,112 KB
testcase_01 AC 30 ms
10,112 KB
testcase_02 AC 29 ms
10,112 KB
testcase_03 AC 29 ms
10,112 KB
testcase_04 AC 29 ms
10,112 KB
testcase_05 AC 29 ms
10,112 KB
testcase_06 AC 30 ms
10,112 KB
testcase_07 AC 31 ms
10,112 KB
testcase_08 AC 31 ms
10,112 KB
testcase_09 AC 30 ms
10,112 KB
testcase_10 AC 29 ms
10,112 KB
testcase_11 AC 29 ms
10,112 KB
testcase_12 AC 90 ms
20,832 KB
testcase_13 AC 88 ms
21,096 KB
testcase_14 AC 88 ms
21,096 KB
testcase_15 AC 48 ms
12,480 KB
testcase_16 AC 48 ms
12,480 KB
testcase_17 AC 48 ms
12,484 KB
testcase_18 AC 90 ms
20,832 KB
testcase_19 AC 90 ms
20,832 KB
testcase_20 AC 90 ms
20,832 KB
testcase_21 AC 78 ms
20,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int,input().split())
K-=1
A=list(map(int,input().split()))
ans1=0
ans2=0
for i in range(K+1,N):
  if A[i]==0:
    break
  elif A[i]==1:
    ans1+=1
    break
  else:
    ans1+=A[i]
for i in range(K-1,-1,-1):
  if A[i]==0:
    break
  elif A[i]==1:
    ans2+=1
    break
  else:
    ans2+=A[i]
if A[K]==0:
  print(0)
elif A[K]==1:
  print(max(ans1,ans2)+A[K])
else:
  print(ans1+ans2+A[K])
0