結果

問題 No.1007 コイン集め
ユーザー stngstng
提出日時 2022-08-18 11:31:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 535 bytes
コンパイル時間 186 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 79,488 KB
最終ジャッジ日時 2024-04-15 19:59:35
合計ジャッジ時間 2,720 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,224 KB
testcase_01 AC 39 ms
52,404 KB
testcase_02 AC 39 ms
52,480 KB
testcase_03 AC 42 ms
51,712 KB
testcase_04 WA -
testcase_05 AC 39 ms
51,840 KB
testcase_06 AC 38 ms
52,608 KB
testcase_07 AC 40 ms
51,968 KB
testcase_08 AC 39 ms
52,092 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 68 ms
78,464 KB
testcase_13 AC 68 ms
79,104 KB
testcase_14 AC 66 ms
79,488 KB
testcase_15 AC 54 ms
70,400 KB
testcase_16 AC 54 ms
70,400 KB
testcase_17 AC 54 ms
70,272 KB
testcase_18 AC 65 ms
78,080 KB
testcase_19 AC 61 ms
76,544 KB
testcase_20 WA -
testcase_21 AC 64 ms
78,080 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))
else:
    print(r+l+a[k-1])
0