結果

問題 No.45 回転寿司
ユーザー CsTarepanda
提出日時 2019-03-06 15:44:32
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 513 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 44,676 KB
最終ジャッジ日時 2024-06-23 14:35:45
合計ジャッジ時間 20,453 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 3 WA * 27
権限があれば一括ダウンロードができます

ソースコード

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]
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 = free + f(oxo, 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