結果

問題 No.1007 コイン集め
ユーザー stngstng
提出日時 2022-08-18 11:32:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 542 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 78,848 KB
最終ジャッジ日時 2024-04-15 20:00:08
合計ジャッジ時間 2,048 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,096 KB
testcase_01 AC 37 ms
51,712 KB
testcase_02 AC 38 ms
51,840 KB
testcase_03 AC 38 ms
52,352 KB
testcase_04 AC 38 ms
52,480 KB
testcase_05 AC 38 ms
52,096 KB
testcase_06 AC 39 ms
51,712 KB
testcase_07 AC 39 ms
52,480 KB
testcase_08 AC 39 ms
52,352 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 69 ms
78,720 KB
testcase_13 AC 69 ms
78,848 KB
testcase_14 AC 68 ms
78,720 KB
testcase_15 AC 55 ms
70,528 KB
testcase_16 AC 53 ms
70,400 KB
testcase_17 AC 54 ms
70,400 KB
testcase_18 AC 66 ms
77,696 KB
testcase_19 AC 63 ms
76,672 KB
testcase_20 WA -
testcase_21 AC 66 ms
77,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k = map(int,input().split())
a = [int(i) for i in input().split()]

if a[k-1] == 0:
    print(0)
    exit()

l = 0
now = k-2

for i in range(n):
    if now != -1:
        if a[now] > 1:
            l += a[now]
        else:
            l += a[now]
            break
        now -= 1

r = 0
now = k

for i in range(n):
    if now != n:
        if a[now] > 1:
            r += a[now]
        else:
            r += a[now]
            break
        now += 1
    #print(r)

if a[k-1] == 1:
    print(max(r,l,a[k-1]))
else:
    print(r+l+a[k-1])
0