結果
問題 |
No.2982 Logic Battle
|
ユーザー |
![]() |
提出日時 | 2024-12-07 01:14:51 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 852 bytes |
コンパイル時間 | 2,966 ms |
コンパイル使用メモリ | 252,780 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-07 01:15:32 |
合計ジャッジ時間 | 38,931 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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>>; int 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) 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(j,5001) rep(k,3) rep(l,3){ if(k==l) continue; if(old[j][k]==-1) continue; int tmp=max(0,min(5000,j+(int)A[i+1][l]-1)); dp[tmp][l]=max(dp[tmp][l],old[j][k]+(ll)j+(ll)A[i+1][l]); } } ll ans=0; rep(j,5001) rep(k,3) ans=max(ans,dp[j][k]); cout<<ans<<endl; return 0; }