Submission #61576335


Source Code Expand

use std::collections::VecDeque;

#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;

fn main() {
    input!{
        n: usize,
        a: [u64; n],
    }
    let v = a[0..n/2].iter().copied().collect_vec();
    let w = a[n/2..].iter().copied().collect_vec();
    let mut vi = 0;
    let mut wi = 0;

    let mut ans = 0;
    while vi < v.len() && wi < w.len() {
        if v[vi]*2 <= w[wi] {
            ans += 1u64;
            vi += 1;
            wi += 1;
        } else {
            wi += 1;
        }
    }
    println!("{}", ans);
}

pub trait Debuggable {
    fn debug_string(&self) -> String;
}

impl<T: std::fmt::Debug + std::fmt::Display> Debuggable for Vec<T> {
    fn debug_string(&self) -> String {
        use itertools::Itertools;
        use std::iter::repeat;
        if let Some(max_size) = self.iter()
            .enumerate()
            .map(|(i, x)| (format!("{:?}", x).len()).max(format!("{:?}", i).len()))
            .max() {
                let mut idx = String::from("idx |");   
                let mut val = String::from("val |");   
                for (i, xi) in self.iter().enumerate() {
                    idx.push_str(
                        &format!(" {:>w$} |", i, w=max_size)
                    );
                    val.push_str(
                        &format!(" {:>w$} |", xi, w=max_size)
                    );
                }

                format!("{}\n{}\n{}\n", idx, repeat('-').take(idx.len()).join(""), val)
            } else {
                format!("idx | \nval |\n")
            }
    }
}

impl<T: std::fmt::Debug + std::fmt::Display> Debuggable for std::collections::BTreeSet<T> {
    fn debug_string(&self) -> String {
        use itertools::Itertools;
        format!("{{ {} }}", self.iter().join(", "))
    }
}

impl<T, U> Debuggable for std::collections::BTreeMap<T, U> 
where T: std::fmt::Debug + std::fmt::Display, U: std::fmt::Debug + std::fmt::Display
{
    fn debug_string(&self) -> String {
        use itertools::Itertools;
        format!(
            "{{\n{}\n }}", self.iter()
                .map(|(k, v)| format!("{k} -> {v}, "))
                .join("\n")
        )
    }
}

// lg! マクロの定義
#[macro_export]
macro_rules! lg {
    ($val:expr) => {
        #[cfg(feature = "local")]
        {
            {
                use Debuggable;
                let val = &$val;
                eprintln!(
                    "[{}:{}] {} = \n{}",
                    file!(),
                    line!(),
                    stringify!($val),
                    val.debug_string()
                );
                val
            }
        }
    }
}
    

Submission Info

Submission Time
Task E - Simultaneous Kagamimochi
User ardRiriy
Language Rust (rustc 1.70.0)
Score 450
Code Size 2659 Byte
Status AC
Exec Time 18 ms
Memory 14576 KiB

Compile Error

warning: unused import: `std::collections::VecDeque`
 --> src/main.rs:1:5
  |
1 | use std::collections::VecDeque;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: the item `Itertools` is imported redundantly
  --> src/main.rs:36:13
   |
4  | use itertools::Itertools;
   |     -------------------- the item `Itertools` is already imported here
...
36 |         use itertools::Itertools;
   |             ^^^^^^^^^^^^^^^^^^^^

warning: the item `Itertools` is imported redundantly
  --> src/main.rs:62:13
   |
4  | use itertools::Itertools;
   |     -------------------- the item `Itertools` is already imported here
...
62 |         use itertools::Itertools;
   |             ^^^^^^^^^^^^^^^^^^^^

warning: the item `Itertools` is imported redundantly
  --> src/main.rs:71:13
   |
4  | use itertools::Itertools;
   |     -------------------- the item `Itertools` is already imported here
...
71 |         use itertools::Itertools;
   |             ^^^^^^^^^^^^^^^^^^^^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 450 / 450
Status
AC × 3
AC × 41
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt, 01_random_35.txt, 02_handmade_36.txt, 02_handmade_37.txt, 02_handmade_38.txt, 02_handmade_39.txt, 02_handmade_40.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 1932 KiB
00_sample_01.txt AC 1 ms 1848 KiB
00_sample_02.txt AC 1 ms 1932 KiB
01_random_03.txt AC 17 ms 14528 KiB
01_random_04.txt AC 17 ms 14468 KiB
01_random_05.txt AC 17 ms 14380 KiB
01_random_06.txt AC 17 ms 14440 KiB
01_random_07.txt AC 17 ms 14464 KiB
01_random_08.txt AC 2 ms 3360 KiB
01_random_09.txt AC 17 ms 14292 KiB
01_random_10.txt AC 10 ms 8876 KiB
01_random_11.txt AC 17 ms 14464 KiB
01_random_12.txt AC 17 ms 14492 KiB
01_random_13.txt AC 17 ms 14112 KiB
01_random_14.txt AC 17 ms 14316 KiB
01_random_15.txt AC 17 ms 14296 KiB
01_random_16.txt AC 16 ms 14292 KiB
01_random_17.txt AC 18 ms 14540 KiB
01_random_18.txt AC 17 ms 14320 KiB
01_random_19.txt AC 17 ms 14332 KiB
01_random_20.txt AC 17 ms 14428 KiB
01_random_21.txt AC 17 ms 14400 KiB
01_random_22.txt AC 17 ms 14340 KiB
01_random_23.txt AC 18 ms 14540 KiB
01_random_24.txt AC 17 ms 14372 KiB
01_random_25.txt AC 18 ms 14516 KiB
01_random_26.txt AC 17 ms 14488 KiB
01_random_27.txt AC 18 ms 14576 KiB
01_random_28.txt AC 16 ms 14208 KiB
01_random_29.txt AC 16 ms 14112 KiB
01_random_30.txt AC 17 ms 14052 KiB
01_random_31.txt AC 17 ms 14356 KiB
01_random_32.txt AC 17 ms 14040 KiB
01_random_33.txt AC 10 ms 8788 KiB
01_random_34.txt AC 14 ms 11620 KiB
01_random_35.txt AC 11 ms 9748 KiB
02_handmade_36.txt AC 1 ms 1800 KiB
02_handmade_37.txt AC 1 ms 1936 KiB
02_handmade_38.txt AC 13 ms 13004 KiB
02_handmade_39.txt AC 17 ms 14536 KiB
02_handmade_40.txt AC 8 ms 10552 KiB