結果

問題 No.2889 Rusk
コンテスト
ユーザー にしろ
提出日時 2024-09-19 18:58:24
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 294 ms / 2,000 ms
コード長 596 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 210 ms
コンパイル使用メモリ 85,048 KB
実行使用メモリ 146,240 KB
最終ジャッジ日時 2026-04-08 07:00:35
合計ジャッジ時間 10,282 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 52
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n=int(input())
taste=[[1**18]*n for _ in range(3)]
for i in range(3):
    taste[i]=list(map(int,input().split()))
dp=[[-1**18]*3 for _ in range(3)]
dp[0][0]=0
for i in range(n):
    ndp=[[1**18]*3 for _ in range(3)]
    for x in range(3):
        for y in range(3):
            for a in range(2):
                for b in range(2):
                    if x+a>2 or y+b>2:
                        continue
                    ndp[x+a][y+b]=max(ndp[x+a][y+b],dp[x][y]+taste[(x+a)%2+(y+b)%2][i])
    dp=ndp
ans=-1**18
for x in range(3):
    for y in range(3):
        ans=max(ans,dp[x][y])
print(ans)
0