結果

問題 No.1007 コイン集め
ユーザー uni_pythonuni_python
提出日時 2020-08-10 23:23:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 781 bytes
コンパイル時間 777 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 82,688 KB
最終ジャッジ日時 2024-04-17 06:59:26
合計ジャッジ時間 2,273 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,096 KB
testcase_01 AC 41 ms
51,584 KB
testcase_02 AC 41 ms
51,456 KB
testcase_03 AC 36 ms
52,096 KB
testcase_04 AC 37 ms
52,096 KB
testcase_05 AC 36 ms
51,968 KB
testcase_06 AC 40 ms
51,968 KB
testcase_07 AC 37 ms
51,968 KB
testcase_08 AC 38 ms
51,840 KB
testcase_09 WA -
testcase_10 AC 37 ms
52,096 KB
testcase_11 WA -
testcase_12 AC 60 ms
81,280 KB
testcase_13 AC 61 ms
81,408 KB
testcase_14 AC 63 ms
81,536 KB
testcase_15 AC 55 ms
76,672 KB
testcase_16 AC 55 ms
76,288 KB
testcase_17 AC 55 ms
76,672 KB
testcase_18 AC 63 ms
81,664 KB
testcase_19 AC 63 ms
81,792 KB
testcase_20 WA -
testcase_21 AC 62 ms
82,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,K=MI()
    K-=1
    A=LI()
    if A[K]==0:
        print(0)
        exit()
    if min(A)>=2:
        print(sum(A))
    else:
        ans=A[K]
        for i in range(K+1,N):
            if A[i]==1:
                ans+=1
                break
            elif A[i]==0:
                break
            else:
                ans+=A[i]
        for i in range(K-1,-1,-1):
            if A[i]==1:
                ans+=1
                break
            elif A[i]==0:
                break
            else:
                ans+=A[i]
        print(ans)
            
        

        


main()
0