結果

問題 No.2982 Logic Battle
ユーザー makichan
提出日時 2024-12-07 00:32:37
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,360 bytes
コンパイル時間 5,840 ms
コンパイル使用メモリ 314,304 KB
実行使用メモリ 590,976 KB
最終ジャッジ日時 2024-12-07 00:32:59
合計ジャッジ時間 18,615 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11 WA * 9 MLE * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using mint = atcoder::static_modint<998244353>;
//using mint = atcoder::static_modint<1000000007>;
using namespace std;
using namespace atcoder;
using ld = long double;
using ll = long long;
#define mp(a,b) make_pair(a,b)
#define rep(i,s,n) for(int i=s; i<n; i++)
const vector<int> dx{1,0,-1,0},dy{0,1,0,-1};

int main(){
    int n;cin >> n;
    vector<vector<int>> a(n+1,vector<int>(3));
    rep(i,1,n+1)rep(j,0,3)cin >> a[i][j];

    vector<vector<vector<ll>>> dp(n+1,vector<vector<ll>>(3,vector<ll>(5001,-1)));
    vector<vector<ll>> dpover(n+1,vector<ll>(3,-1));
    rep(j,0,3)dp[0][j][0]=0;
    rep(i,1,n+1)rep(j,0,3){
        rep(k,0,3)if(k!=j){
            rep(l,0,5001)if(dp[i-1][j][l]>=0){
                int newatk=l+a[i][k];
                if(newatk-1<=5000)dp[i][k][max(0,newatk-1)]=max(dp[i][k][max(0,newatk-1)],dp[i-1][j][l]+newatk);
                else{
                    ll p=n-i+1;
                    p*=(2*newatk-n+i);
                    p/=2;
                    dpover[i][k]=max(dpover[i][k],dpover[i-1][j]+p);
                }
            }
            if(dpover[i-1][j]>=0)dpover[i][k]=max(dpover[i][k],dpover[i-1][j]+(ll)a[i][k]*(n-i+1));
        }
    }
    ll ans=0;
    rep(j,0,3)rep(k,0,5001)ans=max(ans,dp[n][j][k]);
    rep(j,0,3)ans=max(ans,dpover[n][j]);
    cout << ans;
}
0