結果
問題 |
No.2889 Rusk
|
ユーザー |
![]() |
提出日時 | 2025-09-02 20:03:41 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 48 ms / 2,000 ms |
コード長 | 704 bytes |
コンパイル時間 | 13,672 ms |
コンパイル使用メモリ | 384,388 KB |
実行使用メモリ | 13,164 KB |
最終ジャッジ日時 | 2025-09-02 20:04:00 |
合計ジャッジ時間 | 18,126 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 52 |
ソースコード
use proconio::input; fn main() { input! { n: usize, a: [[i64; n]; 3], } let mut dp = [[-1; 2]; 5]; dp[0] = [0; 2]; for i in 0..n { let mut ndp = [[-1; 2]; 5]; for j in 0..5 { for k in 0..2 { if dp[j][k] == -1 { continue; } for nj in j..5 { // 01010 or 01210 let target = nj & 1 + if nj == 2 { 2 * k } else { 0 }; ndp[nj][k] = ndp[nj][k].max(dp[j][k] + a[target][i]); } } } dp = ndp; } let ans = dp.iter().flatten().max().unwrap(); println!("{ans}"); }