結果
問題 | No.2560 A_1 < A_2 < ... < A_N |
ユーザー |
![]() |
提出日時 | 2023-11-18 15:37:44 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 109 ms / 2,000 ms |
コード長 | 1,510 bytes |
コンパイル時間 | 12,344 ms |
コンパイル使用メモリ | 384,116 KB |
実行使用メモリ | 10,112 KB |
最終ジャッジ日時 | 2024-09-26 05:49:25 |
合計ジャッジ時間 | 14,483 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 15 |
ソースコード
macro_rules! input { ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char) .skip_while(|c|c.is_whitespace()) .take_while(|c|!c.is_whitespace()) .collect() }; input_inner!{next, $($r)*} }; } macro_rules! input_inner { ($next:expr) => {}; ($next:expr,) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; } macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ($(read_value!($next, $t)),*) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error")); } fn main() { input! { t: usize, query: [(usize, usize); t], } for i in 0..t { let (n, x) = query[i]; if (1..=n).sum::<usize>() > x { println!("-1"); continue; } let mut ans = (1..=n).collect::<Vec<usize>>(); let diff = x - ans.iter().sum::<usize>(); ans[n - 1] += diff; let line = ans .iter() .map(|&x| x.to_string()) .collect::<Vec<String>>() .join(" "); println!("{}", line); } }