結果

問題 No.1007 コイン集め
ユーザー kozykozy
提出日時 2021-05-08 23:54:22
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
WA  
実行時間 -
コード長 388 bytes
コンパイル時間 1,117 ms
コンパイル使用メモリ 11,772 KB
実行使用メモリ 20,864 KB
最終ジャッジ日時 2023-10-17 09:01:58
合計ジャッジ時間 2,481 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,144 KB
testcase_01 AC 27 ms
10,144 KB
testcase_02 WA -
testcase_03 AC 27 ms
10,144 KB
testcase_04 AC 28 ms
10,144 KB
testcase_05 AC 27 ms
10,144 KB
testcase_06 AC 28 ms
10,144 KB
testcase_07 AC 28 ms
10,144 KB
testcase_08 AC 28 ms
10,144 KB
testcase_09 AC 28 ms
10,144 KB
testcase_10 AC 27 ms
10,144 KB
testcase_11 AC 28 ms
10,144 KB
testcase_12 AC 87 ms
20,864 KB
testcase_13 AC 88 ms
20,864 KB
testcase_14 AC 86 ms
20,864 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 86 ms
20,864 KB
testcase_19 AC 88 ms
20,864 KB
testcase_20 AC 88 ms
20,864 KB
testcase_21 AC 76 ms
20,864 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):
  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