結果
問題 |
No.1869 Doubling?
|
ユーザー |
|
提出日時 | 2022-09-25 15:50:15 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 945 bytes |
コンパイル時間 | 13,941 ms |
コンパイル使用メモリ | 379,876 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-22 12:59:57 |
合計ジャッジ時間 | 13,646 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 WA * 9 |
ソースコード
fn main() { let mut nm = String::new(); std::io::stdin().read_line(&mut nm).ok(); let nm: Vec<usize> = nm.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let n = nm[0]; let m = nm[1]; if m == 1 { println!("{}", n); return; } let mut start = m; let mut stack = vec![]; while stack.len() < n && start > 1 { stack.push(start); if start & 1 == 1 { start = (start+1)/2; } else { start /= 2; } } let mut result = stack.iter().sum::<usize>() + (n - stack.len()) * 1; let mut start = m-1; let mut stack = vec![]; while stack.len() < n && start > 1 { stack.push(start); if start & 1 == 1 { start = (start+1)/2; } else { start /= 2; } } result = result.max(stack.iter().sum::<usize>() + (n - stack.len()) * 1); println!("{}", result); }