結果

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

テストケース

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

ソースコード

diff #

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


if __name__ == '__main__':
    main()

0