結果
問題 |
No.2056 非力なレッド
|
ユーザー |
![]() |
提出日時 | 2022-08-26 22:03:02 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 16 ms / 2,000 ms |
コード長 | 1,104 bytes |
コンパイル時間 | 11,777 ms |
コンパイル使用メモリ | 379,908 KB |
実行使用メモリ | 5,632 KB |
最終ジャッジ日時 | 2024-10-13 22:39:06 |
合計ジャッジ時間 | 13,722 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
コンパイルメッセージ
warning: variable `A` should have a snake case name --> src/main.rs:12:9 | 12 | let A: Vec<usize> = { | ^ help: convert the identifier to snake case: `a` | = note: `#[warn(non_snake_case)]` on by default
ソースコード
fn main() { let (n, x, k): (usize, usize, usize) = { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); let mut iter = line.split_whitespace(); ( iter.next().unwrap().parse().unwrap(), iter.next().unwrap().parse().unwrap(), iter.next().unwrap().parse().unwrap(), ) }; let A: Vec<usize> = { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); line.split_whitespace() .map(|x| x.parse().unwrap()) .collect() }; let mut ans = vec![0;n]; for i in 0..n{ let mut a=A[i]; let mut score=0; while a>=x{ score+=1; a/=2; } ans[i]=score; } let mut lans=0; let mut max_a=0; for i in 0..n{ let xi=n-1-i; if ans[xi]>max_a{ lans+=(ans[xi]-max_a)*(xi+1); max_a=ans[xi]; } } if lans<=k{ println!("Yes"); } else{ println!("No"); } }