結果
問題 | No.2803 Bocching Star |
ユーザー |
![]() |
提出日時 | 2024-09-14 19:50:03 |
言語 | Rust (1.83.0 + proconio) |
結果 |
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 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
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(" "));}}