結果
問題 | No.2486 Don't come next to me |
ユーザー | ikoma |
提出日時 | 2023-09-29 22:33:15 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 40 ms / 2,000 ms |
コード長 | 4,472 bytes |
コンパイル時間 | 23,709 ms |
コンパイル使用メモリ | 376,244 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-22 16:33:03 |
合計ジャッジ時間 | 16,962 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 35 ms
5,248 KB |
testcase_01 | AC | 31 ms
5,248 KB |
testcase_02 | AC | 10 ms
5,376 KB |
testcase_03 | AC | 23 ms
5,376 KB |
testcase_04 | AC | 32 ms
5,376 KB |
testcase_05 | AC | 23 ms
5,376 KB |
testcase_06 | AC | 24 ms
5,376 KB |
testcase_07 | AC | 6 ms
5,376 KB |
testcase_08 | AC | 11 ms
5,376 KB |
testcase_09 | AC | 28 ms
5,376 KB |
testcase_10 | AC | 24 ms
5,376 KB |
testcase_11 | AC | 14 ms
5,376 KB |
testcase_12 | AC | 7 ms
5,376 KB |
testcase_13 | AC | 40 ms
5,376 KB |
testcase_14 | AC | 12 ms
5,376 KB |
testcase_15 | AC | 24 ms
5,376 KB |
testcase_16 | AC | 6 ms
5,376 KB |
testcase_17 | AC | 11 ms
5,376 KB |
testcase_18 | AC | 9 ms
5,376 KB |
testcase_19 | AC | 11 ms
5,376 KB |
testcase_20 | AC | 1 ms
5,376 KB |
testcase_21 | AC | 1 ms
5,376 KB |
testcase_22 | AC | 1 ms
5,376 KB |
ソースコード
#![allow(unused_imports, dead_code, unused_macros, unused_variables, non_snake_case, unused_parens)] use std::cmp::{min,max,Ordering,Reverse}; use std::mem::swap; use std::collections::{VecDeque,LinkedList,HashMap,BTreeMap,HashSet,BTreeSet,BinaryHeap}; const MOD:u64 = 1_000_000_007; const INF:i64 = 0x7fff_ffff_ffff_ffff; macro_rules! min {($a:expr $(,)*) => {{$a}};($a:expr, $b:expr $(,)*) => {{std::cmp::min($a, $b)}};($a:expr, $($rest:expr),+ $(,)*) => {{std::cmp::min($a, min!($($rest),+))}};} macro_rules! max {($a:expr $(,)*) => {{$a}};($a:expr, $b:expr $(,)*) => {{std::cmp::max($a, $b)}};($a:expr, $($rest:expr),+ $(,)*) => {{std::cmp::max($a, max!($($rest),+))}};} macro_rules! mulvec {($x:expr; $s:expr) => {vec![$x; $s]};($x:expr; $s0:expr; $( $s:expr );+) => {mulvec![vec![$x; $s0]; $( $s );+ ]};} trait ChMaxMin<T> { fn chmax(&mut self, v: T) -> bool; fn chmin(&mut self, v: T) -> bool; } impl<T: PartialOrd> ChMaxMin<T> for Option<T> { fn chmax(&mut self, v: T) -> bool { if self.is_none() || v > *self.as_ref().unwrap() { *self = Some(v); true } else { false } } fn chmin(&mut self, v: T) -> bool { if self.is_none() || v < *self.as_ref().unwrap() { *self = Some(v); true } else { false } } } impl<T: PartialOrd> ChMaxMin<T> for T { fn chmax(&mut self, v: T) -> bool { if v > *self { *self = v; true } else { false } } fn chmin(&mut self, v: T) -> bool { if v < *self { *self = v; true } else { false } } } trait Bisect<T> { fn bisect_left(&self, x:T) -> usize; fn bisect_right(&self, x:T) -> usize; } impl <T: PartialOrd> Bisect<T> for Vec<T> { fn bisect_left(&self, x:T) -> usize { let mut ok = self.len(); let mut ng = !0; while (ok-ng)>1 { let m = (ok+ng)/2; if self[m] >= x { ok = m; }else{ ng = m; } } ok } fn bisect_right(&self, x:T) -> usize { let mut ok = self.len(); let mut ng = !0; while (ok-ng)>1 { let m = (ok+ng)/2; if self[m] > x { ok = m; }else{ ng = m; } } ok } } fn solve() { input! { n: usize, m: usize, A:[usize;m], } let mut ans = n-m; for i in 0..m-1 { let mut d = A[i+1]-A[i]-1; if d < 3 {continue} let mut x = 1; while d > 2 { if (d & 1) == 1 { ans-=x; x<<=1; }else{ break; } d >>= 1; } } println!("{}", ans); } fn main() { std::thread::Builder::new() .stack_size(128 * 1024 * 1024) .spawn(|| solve()).unwrap() .join().unwrap(); } mod _input { // https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 #[macro_export] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes .by_ref() .map(|r|r.unwrap() as char) .skip_while(|c|c.is_whitespace()) .take_while(|c|!c.is_whitespace()) .collect() }; input_inner!{next, $($r)*} }; } #[macro_export] macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; } #[macro_export] macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; } }