結果

問題 No.1007 コイン集め
ユーザー kozykozy
提出日時 2021-05-08 23:53:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 383 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 11,864 KB
実行使用メモリ 20,868 KB
最終ジャッジ日時 2023-10-17 09:00:49
合計ジャッジ時間 2,210 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,132 KB
testcase_01 WA -
testcase_02 AC 29 ms
10,132 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 30 ms
10,132 KB
testcase_11 AC 29 ms
10,132 KB
testcase_12 AC 90 ms
20,852 KB
testcase_13 AC 89 ms
20,852 KB
testcase_14 AC 89 ms
20,852 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 91 ms
20,852 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 77 ms
20,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int,input().split())
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):
  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