結果
問題 | No.1628 Sorting Integers (MAX of M) |
ユーザー | fukafukatani |
提出日時 | 2021-07-30 21:50:37 |
言語 | Rust (1.77.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 1,065 bytes |
コンパイル時間 | 6,089 ms |
コンパイル使用メモリ | 149,480 KB |
実行使用メモリ | 4,372 KB |
最終ジャッジ日時 | 2023-10-14 04:19:37 |
合計ジャッジ時間 | 5,853 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,348 KB |
testcase_01 | AC | 1 ms
4,352 KB |
testcase_02 | AC | 1 ms
4,352 KB |
testcase_03 | AC | 1 ms
4,356 KB |
testcase_04 | AC | 1 ms
4,352 KB |
testcase_05 | AC | 1 ms
4,352 KB |
testcase_06 | AC | 1 ms
4,352 KB |
testcase_07 | AC | 1 ms
4,372 KB |
testcase_08 | AC | 1 ms
4,352 KB |
testcase_09 | AC | 1 ms
4,352 KB |
ソースコード
#![allow(unused_imports)] use std::cmp::*; use std::collections::*; use std::io::Write; use std::ops::Bound::*; #[allow(unused_macros)] macro_rules! debug { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), std::io::stderr()); writeln!(err, "{} = {:?}", e, $e).unwrap() })* }; } fn main() { let n = read::<usize>(); let mut numbers = vec![]; let c = read_vec::<i64>(); for i in 1..=9 { for _ in 0..c[i - 1] { numbers.push(i as i64); } } numbers.sort(); let mut ans = 0i64; let mut coef = 1; for i in 0..n { ans += coef * numbers[i]; coef *= 10; } println!("{}", ans); } fn read<T: std::str::FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec<T: std::str::FromStr>() -> Vec<T> { read::<String>() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() }