結果

問題 No.1007 コイン集め
ユーザー kohei2019kohei2019
提出日時 2022-07-11 23:38:12
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,040 bytes
コンパイル時間 357 ms
コンパイル使用メモリ 87,112 KB
実行使用メモリ 91,404 KB
最終ジャッジ日時 2023-09-04 21:39:38
合計ジャッジ時間 3,965 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,064 KB
testcase_01 AC 74 ms
70,968 KB
testcase_02 AC 74 ms
71,196 KB
testcase_03 AC 75 ms
70,840 KB
testcase_04 WA -
testcase_05 AC 77 ms
71,028 KB
testcase_06 AC 77 ms
71,104 KB
testcase_07 AC 80 ms
70,876 KB
testcase_08 AC 74 ms
71,140 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 100 ms
91,216 KB
testcase_13 AC 101 ms
91,300 KB
testcase_14 AC 99 ms
90,896 KB
testcase_15 AC 90 ms
88,228 KB
testcase_16 AC 91 ms
88,264 KB
testcase_17 AC 91 ms
88,204 KB
testcase_18 AC 97 ms
91,160 KB
testcase_19 AC 95 ms
90,508 KB
testcase_20 WA -
testcase_21 AC 97 ms
91,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = map(int,input().split())
lsA = list(map(int,input().split()))
K -= 1
if lsA[K] == 0:
    print(0)
elif lsA[K] == 1:
    a1 = 0
    ind = K+1
    while ind < N:
        if lsA[ind] == 0:
            break
        elif lsA[ind] == 1:
            a1 += 1
            break
        else:
            a1 += lsA[ind]
            ind += 1
    a2 = 0
    ind = K-1
    while 0 <= ind:
        if lsA[ind] == 0:
            break
        elif lsA[ind] == 1:
            a2 += 1
            break
        else:
            a2 += lsA[ind]
            ind -= 1
    print(max(a1,a2))
else:
    a1 = 0
    ind = K+1
    while ind < N:
        if lsA[ind] == 0:
            break
        elif lsA[ind] == 1:
            a1 += 1
            break
        else:
            a1 += lsA[ind]
            ind += 1
    a2 = 0
    ind = K-1
    while 0 <= ind:
        if lsA[ind] == 0:
            break
        elif lsA[ind] == 1:
            a2 += 1
            break
        else:
            a2 += lsA[ind]
            ind -= 1
    print(a1+a2+lsA[K]) 
0