結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
51,712 KB
testcase_01 AC 44 ms
51,584 KB
testcase_02 AC 43 ms
51,968 KB
testcase_03 AC 45 ms
51,968 KB
testcase_04 AC 43 ms
51,584 KB
testcase_05 AC 43 ms
51,968 KB
testcase_06 AC 43 ms
52,096 KB
testcase_07 AC 45 ms
51,584 KB
testcase_08 AC 45 ms
51,712 KB
testcase_09 AC 45 ms
51,712 KB
testcase_10 AC 44 ms
51,968 KB
testcase_11 AC 45 ms
51,968 KB
testcase_12 AC 81 ms
78,208 KB
testcase_13 AC 82 ms
78,464 KB
testcase_14 AC 81 ms
78,976 KB
testcase_15 AC 64 ms
70,144 KB
testcase_16 AC 65 ms
70,144 KB
testcase_17 AC 66 ms
70,144 KB
testcase_18 AC 76 ms
77,440 KB
testcase_19 AC 74 ms
76,672 KB
testcase_20 AC 74 ms
77,568 KB
testcase_21 AC 75 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