結果
| 問題 |
No.2982 Logic Battle
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-12-07 19:26:23 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 882 bytes |
| コンパイル時間 | 3,364 ms |
| コンパイル使用メモリ | 253,580 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-07 19:26:28 |
| 合計ジャッジ時間 | 4,517 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 WA * 25 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
inline void chmax(ll& a, ll b) { if (a < b) a = b; }
int main() {
int n;
cin >> n;
vector a(n, vector<ll>(3));
rep(i, n)rep(j, 3) cin >> a[i][j];
vector dp(n, vector<P>(3));
rep(j, 3) {
dp[0][j].first = a[0][j];
dp[0][j].second = max(0ll, a[0][j]-1);
}
for (int i = 1; i < n; ++i) {
rep(j, 3)rep(k, 3) if (j != k) {
ll now = dp[i-1][k].first + dp[i-1][k].second + a[i][j];
if (now > dp[i][j].first) {
dp[i][j].first = now;
dp[i][j].second = max(0ll, now-dp[i-1][k].first-1);
}
}
}
ll ans = 0;
rep(j, 3) chmax(ans, dp[n-1][j].first);
cout << ans << '\n';
return 0;
}