結果
問題 | No.2803 Bocching Star |
ユーザー | NakLon131 |
提出日時 | 2024-07-12 21:26:01 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 79 ms / 2,000 ms |
コード長 | 1,218 bytes |
コンパイル時間 | 15,720 ms |
コンパイル使用メモリ | 402,076 KB |
実行使用メモリ | 10,916 KB |
最終ジャッジ日時 | 2024-07-12 21:26:21 |
合計ジャッジ時間 | 16,462 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
fn main() { input!{ n: usize, s: i64, mut p: [i64; n], } // 両端を追加 // (値, 元の順番)を昇順でソート p.push(INF); p.insert(0, -INF); let mut pp = Vec::new(); for i in 0..n+2 { pp.push((p[i], i)); } pp.sort(); // 前後を見て、i-sより小さい、かつi+sより大きいものであればよい。 let mut ans = Vec::new(); for i in 1..=n { if pp[i-1].0 < pp[i].0-s && pp[i].0+s < pp[i+1].0 { ans.push(pp[i].1); } } // ansを昇順にして答える ans.sort(); println!("{}", ans.len()); for i in 0..ans.len()-1 { print!("{} ", ans[i]); } println!("{}", ans[ans.len()-1]); } // const MOD17: usize = 1000000007; // const MOD93: usize = 998244353; const INF: i64 = 1 << 60; // let dx = vec![!0, 0, 1, 0]; // 上左下右 // let dy = vec![0, !0, 0, 1]; // 上左下右 // let d = vec!{(!0, 0), (0, !0), (1, 0), (0, 1)}; // 上左下右 #[allow(unused)] use proconio::{input, marker::Chars, marker::Usize1}; #[allow(unused)] use std::{ mem::swap, cmp::min, cmp::max, cmp::Reverse, collections::HashSet, collections::BTreeSet, collections::HashMap, collections::BTreeMap, collections::BinaryHeap, collections::VecDeque, iter::FromIterator, };