結果
| 問題 |
No.2982 Logic Battle
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2024-12-07 00:06:43 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,149 bytes |
| コンパイル時間 | 4,259 ms |
| コンパイル使用メモリ | 253,728 KB |
| 最終ジャッジ日時 | 2025-02-26 11:18:36 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 TLE * 4 -- * 16 |
ソースコード
#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000000LL
long long a[5005][3];
int main(){
int n;
cin>>n;
rep(i,n){
rep(j,3)cin>>a[i][j];
}
vector dp(n+5,vector<long long>(3,-Inf64));
rep(i,3)dp[0][i] = 0;
rep(i,n){
{
vector ndp(n+5,vector<long long>(3,-Inf64));
rep(j,n+5){
rep(k,3){
if(dp[j][k] == -Inf64)continue;
rep(l,3){
if(k == l)continue;
long long nj = j + a[i][l];
long long nv = dp[j][k];
if(nj>=n+5){
nv += ((long long)nj-(n+4)) * (n-i);
nj = n+4;
}
ndp[nj][l] = max(ndp[nj][l],nv);
}
}
}
swap(dp,ndp);
}
{
vector ndp(n+5,vector<long long>(3,-Inf64));
rep(j,n+5){
rep(k,3){
if(dp[j][k] == -Inf64)continue;
ndp[max(j-1,0)][k] = max(ndp[max(j-1,0)][k],dp[j][k] + j);
}
}
swap(dp,ndp);
}
}
long long ans = -Inf64;
rep(i,n+5){
rep(j,3){
ans = max(ans,dp[i][j]);
}
}
cout<<ans<<endl;
return 0;
}
沙耶花