結果
| 問題 | No.45 回転寿司 |
| ユーザー |
CsTarepanda
|
| 提出日時 | 2019-03-06 16:20:32 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 559 ms / 5,000 ms |
| コード長 | 617 bytes |
| 記録 | |
| コンパイル時間 | 328 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 44,480 KB |
| 最終ジャッジ日時 | 2024-12-27 20:01:58 |
| 合計ジャッジ時間 | 22,411 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
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))
CsTarepanda