結果
問題 | No.2560 A_1 < A_2 < ... < A_N |
ユーザー |
|
提出日時 | 2023-12-02 14:57:38 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 114 ms / 2,000 ms |
コード長 | 1,261 bytes |
コンパイル時間 | 12,482 ms |
コンパイル使用メモリ | 379,228 KB |
実行使用メモリ | 9,984 KB |
最終ジャッジ日時 | 2024-09-26 17:45:16 |
合計ジャッジ時間 | 14,493 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 15 |
ソースコード
fn main() { let t = input_value(); for _ in 0..t { let (n, x) = input_tuple(); let mut total = 0_usize; for i in 1..=n { total += i; } if total > x { println!("-1"); continue; } let mut list: Vec<_> = (1..=n).collect(); list[n - 1] += x - total; let text = list .iter() .map(|x| x.to_string()) .collect::<Vec<_>>() .join(" "); println!("{}", text); } } fn input_value<T>() -> T where T: std::str::FromStr, <T as std::str::FromStr>::Err: std::fmt::Debug, { let stdin = std::io::stdin(); let mut buf = String::new(); stdin.read_line(&mut buf).unwrap(); buf = buf.trim_end().to_owned(); let n = buf.parse().unwrap(); n } fn input_tuple<T>() -> (T, T) where T: std::str::FromStr, <T as std::str::FromStr>::Err: std::fmt::Debug, { let stdin = std::io::stdin(); let mut buf = String::new(); stdin.read_line(&mut buf).unwrap(); buf = buf.trim_end().to_owned(); let mut iter = buf.split_whitespace(); let n = iter.next().unwrap().parse().unwrap(); let m = iter.next().unwrap().parse().unwrap(); (n, m) }