結果

問題 No.1110 好きな歌
ユーザー phsplsphspls
提出日時 2020-07-16 23:03:42
言語 Rust
(1.77.0)
結果
AC  
実行時間 274 ms / 5,000 ms
コード長 1,121 bytes
コンパイル時間 10,993 ms
コンパイル使用メモリ 401,960 KB
実行使用メモリ 12,244 KB
最終ジャッジ日時 2024-05-04 04:54:22
合計ジャッジ時間 21,035 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,820 KB
testcase_01 AC 1 ms
6,820 KB
testcase_02 AC 1 ms
6,812 KB
testcase_03 AC 1 ms
6,812 KB
testcase_04 AC 1 ms
6,812 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 1 ms
6,948 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 1 ms
6,944 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 1 ms
6,944 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 1 ms
6,944 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 1 ms
6,940 KB
testcase_24 AC 169 ms
7,004 KB
testcase_25 AC 197 ms
7,340 KB
testcase_26 AC 104 ms
6,944 KB
testcase_27 AC 189 ms
7,296 KB
testcase_28 AC 110 ms
6,944 KB
testcase_29 AC 216 ms
7,192 KB
testcase_30 AC 106 ms
6,940 KB
testcase_31 AC 67 ms
6,940 KB
testcase_32 AC 258 ms
8,144 KB
testcase_33 AC 121 ms
6,940 KB
testcase_34 AC 170 ms
7,864 KB
testcase_35 AC 260 ms
12,232 KB
testcase_36 AC 28 ms
6,940 KB
testcase_37 AC 72 ms
6,944 KB
testcase_38 AC 213 ms
7,044 KB
testcase_39 AC 158 ms
6,944 KB
testcase_40 AC 207 ms
10,240 KB
testcase_41 AC 17 ms
6,944 KB
testcase_42 AC 235 ms
10,748 KB
testcase_43 AC 228 ms
7,544 KB
testcase_44 AC 263 ms
11,220 KB
testcase_45 AC 262 ms
9,040 KB
testcase_46 AC 262 ms
11,220 KB
testcase_47 AC 269 ms
8,148 KB
testcase_48 AC 267 ms
11,216 KB
testcase_49 AC 265 ms
12,244 KB
testcase_50 AC 270 ms
11,348 KB
testcase_51 AC 263 ms
11,220 KB
testcase_52 AC 274 ms
10,452 KB
testcase_53 AC 268 ms
8,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::collections::VecDeque;

fn main() {
    let mut nd = String::new();
    std::io::stdin().read_line(&mut nd).ok();
    let nd: Vec<usize> = nd.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = nd[0];
    let d = nd[1];
    let mut a: Vec<usize> = vec![];
    let mut idx2val: Vec<(usize, usize)> = vec![];
    for i in 0..n {
        let mut ai = String::new();
        std::io::stdin().read_line(&mut ai).ok();
        let ai: usize = ai.trim().parse().unwrap();
        a.push(ai);
        idx2val.push((i, ai));
    }
    idx2val.sort_by_key(|pair| pair.1);
    let mut stack: VecDeque<(usize, usize)> = VecDeque::new();
    let mut result: Vec<usize> = vec![0; n];
    while let Some(pair) = idx2val.pop() {
        stack.push_back(pair);
        while stack.len() > 1 {
            let f = stack.front().unwrap();
            if f.1 >= d + pair.1 {
                let f = stack.pop_front().unwrap();
                result[f.0] = idx2val.len() + 1;
            } else {
                break;
            }
        }
    }
    result.iter().for_each(|i| { println!("{}", i); });
}
0