結果
問題 | No.1083 余りの余り |
ユーザー |
|
提出日時 | 2022-11-22 11:51:40 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 788 bytes |
コンパイル時間 | 12,266 ms |
コンパイル使用メモリ | 388,196 KB |
実行使用メモリ | 10,112 KB |
最終ジャッジ日時 | 2024-09-22 21:14:45 |
合計ジャッジ時間 | 14,972 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 WA * 3 |
ソースコード
fn main() {let mut nk = String::new();std::io::stdin().read_line(&mut nk).ok();let nk: Vec<usize> = nk.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();let n = nk[0];let k = nk[1];let mut a = String::new();std::io::stdin().read_line(&mut a).ok();let mut a: Vec<usize> = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();a.sort();let amins = a[0];let mut dp = vec![0usize; 1<<n];dp[0] = k;for i in 0..1<<n {for j in 0..n {if ((i >> j) & 1) == 1 { continue; }let idx = i | (1 << j);if dp[idx] % amins < dp[i] % a[j] % amins {dp[idx] = dp[idx].max(dp[i] % a[j]);}}}println!("{}", dp[(1<<n)-1]);}