結果
問題 |
No.2982 Logic Battle
|
ユーザー |
![]() |
提出日時 | 2024-12-07 02:06:46 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,105 bytes |
コンパイル時間 | 3,461 ms |
コンパイル使用メモリ | 251,248 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-07 02:07:27 |
合計ジャッジ時間 | 39,141 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 WA * 20 |
ソースコード
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; template <class T> using V=vector<T>; template <class T> using VV=V<V<T>>; ll A[5050][3]; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); VV<ll> dp(5050,V<ll>(3,-1)); int n; cin>>n; rep(i,n) rep(j,3) cin>>A[i][j]; rep(j,3){ if(A[0][j]>=5000) dp[5000][j]=A[0][j]*n-1; else dp[max(0,min(5000,(int)A[0][j]-1))][j]=A[0][j]; } for(int i=0;i<n-1;i++){ VV<ll> old(5050,V<ll>(3,-1)); swap(old,dp); rep(k,3) rep(l,3){ if(k==l) continue; rep(j,5000){ if(old[j][k]==-1) continue; int tmp=max(0,min(5000,j+(int)A[i+1][l]-1)); if(tmp<5000) dp[tmp][l]=max(dp[tmp][l],old[j][k]+j+A[i+1][l]); else dp[5000][l]=max(dp[5000][l],old[j][k]+(j+A[i+1][l])*(n-i-1)-1); } if(old[5000][k]!=-1) dp[5000][l]=max(dp[5000][l],old[5000][k]+A[i+1][l]*(n-i-1)-1); } } ll ans=0; rep(j,5001) rep(k,3) ans=max(ans,dp[j][k]); cout<<ans<<endl; return 0; }