結果
| 問題 |
No.2889 Rusk
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-09-14 22:31:21 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 85 ms / 2,000 ms |
| コード長 | 866 bytes |
| コンパイル時間 | 1,790 ms |
| コンパイル使用メモリ | 196,816 KB |
| 最終ジャッジ日時 | 2025-02-24 08:41:01 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 52 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr int MOD=998244353;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,l,r) for(int i=(l);i<(int)(r);i++)
void chmax(ll &a,ll b){
if(b>a)a=b;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin>>N;
vector A(N,array<int,3>());
rep(i,N)cin>>A[i][0];
rep(i,N)cin>>A[i][1];
rep(i,N)cin>>A[i][2];
vector dp(9,-(ll)1e16);
dp[0]=0;
rep(i,N){
vector ndp(9,-(ll)1e16);
rep(c,3){
rep(k,3){
rep(d,3){
if(k+d<3&&c+d<3){
chmax(ndp[(c+d)*3+(k+d)],dp[c*3+k]+A[i][k+d]);
}
}
rep(j,3){
if(j<=k){
chmax(ndp[c*3+j],dp[c*3+k]+A[i][j]);
}
}
}
}
rep(j,9){
dp[j]=ndp[j];
}
}
cout<<*max_element(dp.begin(),dp.end())<<'\n';
}