結果

問題 No.1007 コイン集め
ユーザー convexineqconvexineq
提出日時 2020-03-06 21:56:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 664 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 79,360 KB
最終ジャッジ日時 2024-04-22 07:27:01
合計ジャッジ時間 2,319 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
51,968 KB
testcase_01 AC 37 ms
52,352 KB
testcase_02 AC 37 ms
51,840 KB
testcase_03 AC 38 ms
51,840 KB
testcase_04 AC 39 ms
51,840 KB
testcase_05 AC 37 ms
52,224 KB
testcase_06 AC 37 ms
52,096 KB
testcase_07 AC 38 ms
51,840 KB
testcase_08 AC 38 ms
52,224 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 56 ms
73,344 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 61 ms
77,312 KB
testcase_20 WA -
testcase_21 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# Your code here!

import sys
readline = sys.stdin.readline
read = sys.stdin.read

n,k,*a = [int(i) for i in read().split()]
k -= 1

v = 0
r = rb = -1
for i in range(k+1,n):
    v += a[i]
    if a[i] == 0:
        r = v
        if rb == -1: rb = v
        break
    elif a[i] == 1:
        rb = v
        
v = 0
l = lb = -1
for i in range(k-1,-1,-1):
    v += a[i]
    if a[i] == 0:
        l = v
        if lb == -1: lb = v
        break
    elif a[i] == 1:
        lb = v

if r == -1: r = 0
if l == -1: l = 0
if rb == -1: rb = 0
if lb == -1: lb = 0

#print(r,rb)
#print(l,lb)

if a[k] == 0:
    print(0)
else:
    print(a[k]+lb+rb)
    









0