結果
| 問題 |
No.2889 Rusk
|
| コンテスト | |
| ユーザー |
FplusFplusF
|
| 提出日時 | 2024-09-14 16:57:00 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 157 ms / 2,000 ms |
| コード長 | 1,481 bytes |
| コンパイル時間 | 3,193 ms |
| コンパイル使用メモリ | 252,488 KB |
| 実行使用メモリ | 47,032 KB |
| 最終ジャッジ日時 | 2024-09-14 16:57:11 |
| 合計ジャッジ時間 | 10,633 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 52 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
using ld=long double;
const ll INF=(1ll<<60);
#define rep(i,n) for (ll i=0;i<(ll)(n);i++)
#define replr(i,l,r) for (ll i=(ll)(l);i<(ll)(r);i++)
#define all(v) v.begin(),v.end()
#define len(v) ((ll)v.size())
template<class T> inline bool chmin(T &a,T b){
if(a>b){
a=b;
return true;
}
return false;
}
template<class T> inline bool chmax(T &a,T b){
if(a<b){
a=b;
return true;
}
return false;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n;
cin >> n;
vector<vector<ll>> v(3,vector<ll>(n));
rep(i,3){
rep(j,n){
cin >> v[i][j];
}
}
vector<vector<vector<ll>>> dp(n+1,vector<vector<ll>>(3,vector<ll>(3,-INF)));
dp[0][0][0]=0;
rep(i,n){
rep(j,3){
rep(k,3){
replr(nj,j,min(3ll,j+2)){
replr(nk,k,min(3ll,k+2)){
ll x=v[0][i];
if((nj==1&&nk!=1)||(nj!=1&&nk==1)) x=v[1][i];
if(nj==1&&nk==1) x=v[2][i];
chmax(dp[i+1][nj][nk],dp[i][j][k]+x);
}
}
}
}
}
ll ans=-INF;
rep(i,3){
rep(j,3){
chmax(ans,dp[n][i][j]);
}
}
cout << ans << '\n';
}
FplusFplusF