結果
問題 |
No.2982 Logic Battle
|
ユーザー |
![]() |
提出日時 | 2024-12-07 00:52:06 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 843 bytes |
コンパイル時間 | 3,159 ms |
コンパイル使用メモリ | 251,000 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-07 00:52:51 |
合計ジャッジ時間 | 42,428 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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) 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)); rep(j,5001) rep(k,3) rep(l,3){ if(k==l) continue; if(dp[j][k]==-1) continue; int tmp=max(0,min(5000,j+(int)A[i+1][l]-1)); old[tmp][l]=max(old[tmp][l],dp[j][k]+j+A[i+1][l]); } swap(old,dp); } ll ans=0; rep(j,5001) rep(k,3) ans=max(ans,dp[j][k]); cout<<ans<<endl; return 0; }