結果
問題 | No.2889 Rusk |
ユーザー |
![]() |
提出日時 | 2024-09-14 01:03:27 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 150 ms / 2,000 ms |
コード長 | 774 bytes |
コンパイル時間 | 3,104 ms |
コンパイル使用メモリ | 253,388 KB |
実行使用メモリ | 46,980 KB |
最終ジャッジ日時 | 2024-09-14 01:03:37 |
合計ジャッジ時間 | 9,078 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 52 |
ソースコード
#include<bits/stdc++.h>using namespace std;typedef long long ll;#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)int main(){ios_base::sync_with_stdio(false);cin.tie(NULL);int n; cin >> n;vector a(3, vector<ll>(n));rep(j,0,3) rep(i,0,n) cin >> a[j][i];// index, used(0-2), now?vector dp(n+1, vector(3, vector<ll>(3,-1e18)));dp[0][0][0] = 0;rep(i,0,n){rep(j,0,3){rep(x,0,3-j){rep(k,0,3){rep(y,0,k+1){if (dp[i][j][k] < 0) continue;dp[i+1][j+x][y+x] = max(dp[i+1][j+x][y+x], dp[i][j][k] + a[y+x][i]);}}}}}ll ans = -1e18;rep(i,0,3){rep(j,0,3){ans = max(ans, dp[n][i][j]);}}cout << ans << '\n';}