結果

問題 No.45 回転寿司
ユーザー CsTarepandaCsTarepanda
提出日時 2019-03-06 16:20:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 147 ms / 5,000 ms
コード長 617 bytes
コンパイル時間 76 ms
コンパイル使用メモリ 10,880 KB
実行使用メモリ 29,848 KB
最終ジャッジ日時 2023-08-27 16:49:41
合計ジャッジ時間 7,946 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
29,724 KB
testcase_01 AC 134 ms
29,680 KB
testcase_02 AC 140 ms
29,716 KB
testcase_03 AC 142 ms
29,580 KB
testcase_04 AC 136 ms
29,748 KB
testcase_05 AC 123 ms
29,688 KB
testcase_06 AC 131 ms
29,716 KB
testcase_07 AC 139 ms
29,820 KB
testcase_08 AC 127 ms
29,696 KB
testcase_09 AC 142 ms
29,720 KB
testcase_10 AC 133 ms
29,716 KB
testcase_11 AC 132 ms
29,704 KB
testcase_12 AC 138 ms
29,736 KB
testcase_13 AC 122 ms
29,652 KB
testcase_14 AC 121 ms
29,552 KB
testcase_15 AC 130 ms
29,604 KB
testcase_16 AC 127 ms
29,848 KB
testcase_17 AC 131 ms
29,768 KB
testcase_18 AC 131 ms
29,692 KB
testcase_19 AC 140 ms
29,708 KB
testcase_20 AC 125 ms
29,716 KB
testcase_21 AC 125 ms
29,644 KB
testcase_22 AC 122 ms
29,628 KB
testcase_23 AC 124 ms
29,648 KB
testcase_24 AC 124 ms
29,696 KB
testcase_25 AC 123 ms
29,560 KB
testcase_26 AC 134 ms
29,712 KB
testcase_27 AC 138 ms
29,744 KB
testcase_28 AC 133 ms
29,708 KB
testcase_29 AC 138 ms
29,684 KB
testcase_30 AC 139 ms
29,800 KB
testcase_31 AC 125 ms
29,676 KB
testcase_32 AC 124 ms
29,692 KB
testcase_33 AC 147 ms
29,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())) + [0] * (3 * 3 - n % 3))
length = len(a)

free, fix = 0, 0
oxo = [True, False, True]
xxo = [False, False, True]
oxx = [True, False, False]
xox = [False, True, False]

def f(array, pos):
    return np.sum(a[pos:pos + 3] * array)

pos = 0

for i in range(length // 3):
    tmp_fix = max(
        free + f(oxo, pos),
        free + f(xxo, pos),
        fix  + f(xxo, pos),
    )
    free = max(
        fix  + f(xox, pos),
        free + f(oxx, pos),
        free + f(xox, pos),
    )
    fix = tmp_fix
    pos += 3

print(max(fix, free))
0