結果

問題 No.1007 コイン集め
ユーザー convexineqconvexineq
提出日時 2020-03-06 22:02:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 63 ms / 1,500 ms
コード長 528 bytes
コンパイル時間 656 ms
コンパイル使用メモリ 82,460 KB
実行使用メモリ 80,592 KB
最終ジャッジ日時 2024-04-22 07:43:53
合計ジャッジ時間 2,552 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,508 KB
testcase_01 AC 35 ms
53,116 KB
testcase_02 AC 35 ms
51,812 KB
testcase_03 AC 36 ms
52,404 KB
testcase_04 AC 37 ms
52,296 KB
testcase_05 AC 37 ms
53,116 KB
testcase_06 AC 35 ms
52,116 KB
testcase_07 AC 38 ms
51,884 KB
testcase_08 AC 38 ms
53,328 KB
testcase_09 AC 37 ms
52,748 KB
testcase_10 AC 37 ms
53,104 KB
testcase_11 AC 38 ms
52,160 KB
testcase_12 AC 63 ms
79,544 KB
testcase_13 AC 60 ms
78,704 KB
testcase_14 AC 60 ms
80,592 KB
testcase_15 AC 54 ms
74,096 KB
testcase_16 AC 55 ms
74,332 KB
testcase_17 AC 54 ms
73,484 KB
testcase_18 AC 58 ms
78,452 KB
testcase_19 AC 58 ms
77,444 KB
testcase_20 AC 58 ms
77,316 KB
testcase_21 AC 58 ms
77,500 KB
権限があれば一括ダウンロードができます

ソースコード

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
rb = 0
for i in range(k+1,n):
    v += a[i]
    if a[i] <= 1:
        rb = v
        break
else:
    rb = v
        
v = 0
lb = 0
for i in range(k-1,-1,-1):
    v += a[i]
    if a[i] <= 1:
        lb = v
        break
else:
    lb = v

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

if a[k] == 0:
    print(0)
elif a[k] == 1:
    print(a[k]+max(lb,rb))
else:
    print(a[k]+lb+rb)
    







0