Submission #1951492


Source Code Expand

fn main() {
    let (n, h): (usize, i32) = readln();
    let mut v: Vec<(i32, i32)> = readlns(n);
    let normal = v.iter().map(|k| k.0).max().unwrap();
    v.sort_by_key(|x| -(x.1));

    let (throw, last_h) = v.iter().map(|x| x.1).fold((0, h), |(throw, rest), x| {
        if rest > 0 && x > normal {
            (throw + 1, rest - x)
        } else {
            (throw, rest)
        }
    });

    let answer = throw + if last_h > 0 {
        (last_h + normal - 1) / normal
    } else {
        0
    };

    println!("{}", answer);
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashSet;

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(
    String,
    bool,
    f32,
    f64,
    isize,
    i8,
    i16,
    i32,
    i64,
    usize,
    u8,
    u16,
    u32,
    u64
);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);

Submission Info

Submission Time
Task D - Katana Thrower
User ichyo
Language Rust (1.15.1)
Score 400
Code Size 2220 Byte
Status AC
Exec Time 29 ms
Memory 4352 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 24
Set Name Test Cases
Sample a01, a02, a03, a04
All a01, a02, a03, a04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24
Case Name Status Exec Time Memory
a01 AC 2 ms 4352 KB
a02 AC 2 ms 4352 KB
a03 AC 2 ms 4352 KB
a04 AC 2 ms 4352 KB
b05 AC 2 ms 4352 KB
b06 AC 29 ms 4352 KB
b07 AC 2 ms 4352 KB
b08 AC 29 ms 4352 KB
b09 AC 2 ms 4352 KB
b10 AC 2 ms 4352 KB
b11 AC 2 ms 4352 KB
b12 AC 2 ms 4352 KB
b13 AC 17 ms 4352 KB
b14 AC 17 ms 4352 KB
b15 AC 17 ms 4352 KB
b16 AC 17 ms 4352 KB
b17 AC 27 ms 4352 KB
b18 AC 26 ms 4352 KB
b19 AC 24 ms 4352 KB
b20 AC 25 ms 4352 KB
b21 AC 26 ms 4352 KB
b22 AC 27 ms 4352 KB
b23 AC 2 ms 4352 KB
b24 AC 3 ms 4352 KB