結果

問題 No.2567 A_1 > A_2 > ... > A_N
ユーザー Kyo_s_sKyo_s_s
提出日時 2023-11-18 15:28:11
言語 Rust
(1.77.0)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 1,751 bytes
コンパイル時間 1,641 ms
コンパイル使用メモリ 189,380 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2023-11-18 15:31:20
合計ジャッジ時間 3,999 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
6,676 KB
testcase_01 AC 20 ms
7,808 KB
testcase_02 AC 23 ms
8,892 KB
testcase_03 AC 21 ms
11,008 KB
testcase_04 AC 24 ms
9,804 KB
testcase_05 AC 26 ms
10,240 KB
testcase_06 AC 121 ms
6,676 KB
testcase_07 AC 120 ms
6,676 KB
testcase_08 AC 120 ms
6,676 KB
testcase_09 AC 144 ms
6,676 KB
testcase_10 AC 120 ms
6,676 KB
testcase_11 AC 1 ms
6,676 KB
testcase_12 AC 1 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
testcase_16 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 ad = (x - (1..=n).sum::<usize>()) / n;
        let mut mo = (x - (1..=n).sum::<usize>()) % n;
        let ans = (1..=n)
            .rev()
            .map(|i| {
                if mo > 0 {
                    mo -= 1;
                    i + ad + 1
                } else {
                    i + ad
                }
            })
            .collect::<Vec<_>>();

        let line = ans
            .iter()
            .map(|i| i.to_string())
            .collect::<Vec<_>>()
            .join(" ");
        println!("{}", line);
    }
}
0