結果
問題 |
No.2982 Logic Battle
|
ユーザー |
|
提出日時 | 2024-12-07 00:10:12 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,257 bytes |
コンパイル時間 | 1,350 ms |
コンパイル使用メモリ | 105,716 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-07 00:10:25 |
合計ジャッジ時間 | 13,440 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 WA * 20 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <climits> using namespace std; int main() { int n; cin >> n; vector<vector<long long>> dp(3, vector<long long>(n + 1, -(1LL << 60))); dp[0][0] = dp[1][0] = dp[2][0] = 0; for (int t = 0; t < n; ++t) { vector<int> A(3); for (int i = 0; i < 3; ++i) { cin >> A[i]; } vector<vector<long long>> ndp(3, vector<long long>(n + 1, -(1LL << 60))); for (int i1 = 0; i1 < 3; ++i1) { for (int i2 = 0; i2 < 3; ++i2) { if (i1 == i2) continue; for (int j = 0; j < n; ++j) { int nj = j + A[i2]; long long nv = dp[i1][j]; if (nj > n) { nv += (n - t) * (nj - n); nj = n; } nv += nj; nj = max(nj - 1, 0); ndp[i2][nj] = max(ndp[i2][nj], nv); } } } dp = ndp; } long long result = -(1LL << 60); for (const auto& row : dp) { result = max(result, *max_element(row.begin(), row.end())); } cout << result << endl; return 0; }