結果

問題 No.2803 Bocching Star
ユーザー well-definedwell-defined
提出日時 2024-09-14 19:46:57
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 1,015 bytes
コンパイル時間 15,921 ms
コンパイル使用メモリ 396,216 KB
実行使用メモリ 21,044 KB
最終ジャッジ日時 2024-09-14 19:47:28
合計ジャッジ時間 22,219 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::input;

fn main () {
    input! {
        n: usize,
        s: i64,
        p: [i64; n],
    }
    if n == 1 {
        println!("{}", 1);
    }
    else if n == 2 {
        println!("{} {}", 1, 2);
    }
    else {
        let mut p = p.iter()
            .enumerate()
            .map(|(i, &x)| {
                (x, i+1)
            })
            .collect::<Vec<_>>();
        p.sort();
        let mut ans = p.windows(3)
            .filter(|w| {
                (w[0].0-w[1].0).abs() > s && (w[2].0-w[1].0).abs() > s
            })
            .collect::<Vec<_>>()
            .iter()
            .map(|&w| {
                w[1].1
            })
            .collect::<Vec<_>>();
        if (p[1].0-p[0].0).abs() > s { ans.push(p[0].1) };
        if (p[n-1].0-p[n-2].0).abs() > s { ans.push(p[n-1].1) };
        ans.sort();
        println!("{}", ans.len());
        println!("{}", ans.iter()
            .map(|&x| x.to_string())
            .collect::<Vec<_>>()
            .join(" "));
    }
}
0