結果
問題 |
No.1416 ショッピングモール
|
ユーザー |
|
提出日時 | 2022-11-08 11:50:05 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 5 ms / 1,000 ms |
コード長 | 646 bytes |
コンパイル時間 | 13,903 ms |
コンパイル使用メモリ | 382,608 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-21 20:34:45 |
合計ジャッジ時間 | 12,916 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
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 mut a: Vec<usize> = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); a.sort(); a.reverse(); let mut result = 0usize; let mut idx = 0; let mut rank = 0; while idx < n { for _ in 0..1<<rank { if idx == n { break; } result += rank * a[idx]; idx += 1; } rank += 1; } println!("{}", result); }