結果

問題 No.2803 Bocching Star
ユーザー well-definedwell-defined
提出日時 2024-09-14 19:50:03
言語 Rust
(1.77.0)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 1,069 bytes
コンパイル時間 14,543 ms
コンパイル使用メモリ 384,140 KB
実行使用メモリ 21,604 KB
最終ジャッジ日時 2024-09-14 19:50:22
合計ジャッジ時間 17,663 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,812 KB
testcase_02 AC 1 ms
6,816 KB
testcase_03 AC 11 ms
6,940 KB
testcase_04 AC 54 ms
10,880 KB
testcase_05 AC 25 ms
6,940 KB
testcase_06 AC 5 ms
6,944 KB
testcase_07 AC 22 ms
6,944 KB
testcase_08 AC 11 ms
6,944 KB
testcase_09 AC 48 ms
9,488 KB
testcase_10 AC 55 ms
9,860 KB
testcase_11 AC 68 ms
14,984 KB
testcase_12 AC 21 ms
6,940 KB
testcase_13 AC 42 ms
8,448 KB
testcase_14 AC 29 ms
6,944 KB
testcase_15 AC 71 ms
16,268 KB
testcase_16 AC 38 ms
9,640 KB
testcase_17 AC 11 ms
6,940 KB
testcase_18 AC 7 ms
6,940 KB
testcase_19 AC 45 ms
9,384 KB
testcase_20 AC 30 ms
7,320 KB
testcase_21 AC 22 ms
6,944 KB
testcase_22 AC 26 ms
6,944 KB
testcase_23 AC 62 ms
12,320 KB
testcase_24 AC 88 ms
20,492 KB
testcase_25 AC 81 ms
17,788 KB
testcase_26 AC 83 ms
18,672 KB
testcase_27 AC 67 ms
13,792 KB
testcase_28 AC 74 ms
16,096 KB
testcase_29 AC 63 ms
12,908 KB
testcase_30 AC 85 ms
19,228 KB
testcase_31 AC 60 ms
11,812 KB
testcase_32 AC 89 ms
21,604 KB
testcase_33 AC 1 ms
6,944 KB
testcase_34 AC 2 ms
6,944 KB
testcase_35 AC 2 ms
6,944 KB
testcase_36 AC 2 ms
6,940 KB
testcase_37 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::input;

fn main () {
    input! {
        n: usize,
        s: i64,
        p: [i64; n],
    }
    if n == 1 {
        println!("{}", 1);
        println!("{}", 1);
    }
    else if n == 2 {
        println!("{}", 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