結果

問題 No.2560 A_1 < A_2 < ... < A_N
ユーザー Kyo_s_sKyo_s_s
提出日時 2023-11-18 15:37:44
言語 Rust
(1.77.0)
結果
AC  
実行時間 117 ms / 2,000 ms
コード長 1,510 bytes
コンパイル時間 2,660 ms
コンパイル使用メモリ 189,016 KB
実行使用メモリ 9,984 KB
最終ジャッジ日時 2023-11-18 15:37:49
合計ジャッジ時間 3,346 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 17 ms
7,168 KB
testcase_02 AC 17 ms
8,124 KB
testcase_03 AC 17 ms
9,984 KB
testcase_04 AC 21 ms
9,036 KB
testcase_05 AC 22 ms
9,344 KB
testcase_06 AC 109 ms
6,676 KB
testcase_07 AC 102 ms
6,676 KB
testcase_08 AC 101 ms
6,676 KB
testcase_09 AC 104 ms
6,676 KB
testcase_10 AC 117 ms
6,676 KB
testcase_11 AC 1 ms
6,676 KB
testcase_12 AC 0 ms
6,676 KB
testcase_13 AC 1 ms
6,676 KB
testcase_14 AC 1 ms
6,676 KB
testcase_15 AC 1 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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);
    }
}
0