結果
問題 | No.1231 Make a Multiple of Ten |
ユーザー | phspls |
提出日時 | 2022-11-11 10:51:09 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 42 ms / 2,000 ms |
コード長 | 642 bytes |
コンパイル時間 | 12,202 ms |
コンパイル使用メモリ | 401,384 KB |
実行使用メモリ | 19,468 KB |
最終ジャッジ日時 | 2024-09-13 06:18:04 |
合計ジャッジ時間 | 14,176 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
ソースコード
fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let n: usize = n.trim().parse().unwrap(); let mut a = String::new(); std::io::stdin().read_line(&mut a).ok(); let a: Vec<usize> = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let mut dp = vec![vec![-1; 10]; n+1]; dp[0][0] = 0; for i in 0..n { for j in 0..10 { if dp[i][j] < 0 { continue; } dp[i+1][j] = dp[i+1][j].max(dp[i][j]); let idx = (j+a[i]) % 10; dp[i+1][idx] = dp[i+1][idx].max(dp[i][j]+1); } } println!("{}", dp[n][0]); }