結果

問題 No.1007 コイン集め
ユーザー AzumabashiAzumabashi
提出日時 2020-04-24 13:40:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 1,010 bytes
コンパイル時間 108 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 21,840 KB
最終ジャッジ日時 2024-04-23 02:28:13
合計ジャッジ時間 2,053 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 AC 31 ms
10,752 KB
testcase_02 AC 30 ms
10,752 KB
testcase_03 AC 31 ms
10,880 KB
testcase_04 AC 30 ms
10,752 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 30 ms
10,880 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 WA -
testcase_16 AC 60 ms
13,152 KB
testcase_17 AC 61 ms
13,156 KB
testcase_18 RE -
testcase_19 AC 74 ms
21,712 KB
testcase_20 WA -
testcase_21 AC 74 ms
21,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    length, start = map(int, input().split())
    start -= 1
    coins = [int(x) for x in input().split()]
    only_1_coin_index = []
    for i in range(length):
        if i == start:
            continue
        if coins[i] == 1:
            only_1_coin_index.append(i)
    answer = coins[start]
    if coins[start] > 1:
        move_range = [0, 0]
        only_1_coin_index.sort()
        if only_1_coin_index[-1] < start:
            answer = sum(coins[only_1_coin_index[-1]:])
        elif start < only_1_coin_index[0]:
            answer = sum(coins[:only_1_coin_index[0] + 1])
        else:
            for i in range(len(only_1_coin_index) - 1):
                if only_1_coin_index[i] < start < only_1_coin_index[i + 1]:
                    move_range[0] = only_1_coin_index[i]
                    move_range[1] = only_1_coin_index[i + 1]
                    break
            answer = sum(coins[move_range[0]:move_range[1] + 1])
    print(answer)


if __name__ == '__main__':
    main()

0