結果

問題 No.1373 Directed Operations
コンテスト
ユーザー tzyvrn
提出日時 2021-02-05 23:15:40
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 1,059 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,939 ms
コンパイル使用メモリ 191,592 KB
実行使用メモリ 10,636 KB
最終ジャッジ日時 2026-03-23 22:16:25
合計ジャッジ時間 3,051 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#[allow(unused_macros)]
macro_rules! getl {
    ( $( $t:ty ),* ) => {
        {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            let s = s.trim_end();
            let mut ws = s.split_whitespace();
            ($(ws.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}

#[allow(unused_macros)]
macro_rules! getl_vec {
    ( $t:ty ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_end();
        s.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect::<Vec<$t>>()
    }};
}

fn main() {
    let n = getl!(usize);
    let a = getl_vec!(usize);
    let mut b = a.clone();
    b.sort();

    let mut v = vec![vec![]; n];
    for i in 2..=n {
        let bi = b[i - 2];
        if bi > i - 1 {
            println!("NO");
            return;
        }
        v[bi].push(i - bi);
    }

    println!("YES");
    for ai in a {
        let c = v[ai].pop().unwrap();
        println!("{}", c);
    }
}
0