Problem:
Score : 300 points

Problem Statement

A programming competition site AtCode provides algorithmic problems.
Each problem is allocated a score based on its difficulty.
Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points.
These p_1 + … + p_D problems are all of the problems available on AtCode.

A user of AtCode has a value called total score.
The total score of a user is the sum of the following two elements:

Base score: the sum of the scores of all problems solved by the user.

Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D).

Takahashi, who is the new user of AtCode, has not solved any problem.
His objective is to have a total score of G or more points.
At least how many problems does he need to solve for this objective?

Constraints

1 ≤ D ≤ 10

1 ≤ p_i ≤ 100

100 ≤ c_i ≤ 10^6

100 ≤ G

All values in input are integers.

c_i and G are all multiples of 100.

It is possible to have a total score of G or more points.

Input

Input is given from Standard Input in the following format:

D G
p_1 c_1
:
p_D c_D

Output

Print the minimum number of problems that needs to be solved in order to have a total score of G or more points. Note that this objective is always achievable (see Constraints).

Sample Input 1

2 700
3 500
5 800

Sample Output 1

3

In this case, there are three problems each with 100 points and five problems each with 200 points. The perfect bonus for solving all the 100-point problems is 500 points, and the perfect bonus for solving all the 200-point problems is 800 points. Takahashi's objective is to have a total score of 700 points or more.

One way to achieve this objective is to solve four 200-point problems and earn a base score of 800 points. However, if we solve three 100-point problems, we can earn the perfect bonus of 500 points in addition to the base score of 300 points, for a total score of 800 points, and we can achieve the objective with fewer problems.

Sample Input 2

2 2000
3 500
5 800

Sample Output 2

7

This case is similar to Sample Input 1, but the Takahashi's objective this time is 2000 points or more. In this case, we inevitably need to solve all five 200-point problems, and by solving two 100-point problems additionally we have the total score of 2000 points.

Sample Input 3

2 400
3 500
5 800

Sample Output 3

2

This case is again similar to Sample Input 1, but the Takahashi's objective this time is 400 points or more. In this case, we only need to solve two 200-point problems to achieve the objective.

Sample Input 4

5 25000
20 1000
40 1000
50 1000
30 1000
1 1000

Sample Output 4

66

There is only one 500-point problem, but the perfect bonus can be earned even in such a case.

Solution in Rust (1.15.1) (judge verdict: Accepted)

pub trait FromFragments: Sized {
    fn fragments_count() -> usize;
    fn from_fragments(fragments: &[&str]) -> Result<Self, String>;
}
impl FromFragments for () {
    fn fragments_count() -> usize {
        1
    }
    fn from_fragments(_fragments: &[&str]) -> Result<(), String> {
        Ok(())
    }
}
impl FromFragments for String {
    fn fragments_count() -> usize {
        1
    }
    fn from_fragments(fragments: &[&str]) -> Result<String, String> {
        Ok(fragments[0].to_string())
    }
}
macro_rules ! impl_from_fragments { ( $ ( $ t : ty ) * ) => { $ ( impl FromFragments for $ t { fn fragments_count ( ) -> usize { 1 } fn from_fragments ( fragments : & [ & str ] ) -> Result <$ t , String > { use std :: str :: FromStr ; <$ t >:: from_str ( fragments [ 0 ] ) . map_err ( | _ | { format ! ( "cannot parse \"{}\" as {}" , fragments [ 0 ] , stringify ! ( $ t ) ) } ) } } ) * } ; }
impl_from_fragments ! ( isize usize i8 u8 i16 u16 i32 u32 i64 u64 f32 f64 ) ;
pub trait FromLine: Sized {
    fn from_line(line: &str) -> Result<Self, String>;
}
fn split_into_fragments(line: &str) -> Vec<&str> {
    #[allow(deprecated)]
    line.trim_right_matches('\n').split_whitespace().collect()
}
impl<T: FromFragments> FromLine for T {
    fn from_line(line: &str) -> Result<T, String> {
        let fragments = split_into_fragments(line);
        if fragments.len() != T::fragments_count() {
            return Err(format!(
                "line \"{}\" has {} fragments, expected {}",
                line,
                fragments.len(),
                T::fragments_count()
            ));
        }
        T::from_fragments(&fragments)
    }
}
impl<T: FromFragments> FromLine for Vec<T> {
    fn from_line(line: &str) -> Result<Vec<T>, String> {
        let n = T::fragments_count();
        let fragments = split_into_fragments(line);
        if fragments.len() % n != 0 {
            return Err(format!(
                "line \"{}\" has {} fragments, expected multiple of {}",
                line,
                fragments.len(),
                n
            ));
        }
        let mut result = Vec::new();
        for chunk in fragments.chunks(n) {
            match T::from_fragments(chunk) {
                Ok(v) => result.push(v),
                Err(msg) => {
                    let flagment_msg = if n == 1 {
                        format!("fragment {}", result.len())
                    } else {
                        let l = result.len();
                        format!("fragments {}-{}", n * l + 1, (n + 1) * l)
                    };
                    return Err(format!("{} of line \"{}\": {}", flagment_msg, line, msg));
                }
            }
        }
        Ok(result)
    }
}
macro_rules ! impl_from_fragments_for_tuples { ( $ t : ident $ var : ident $ count : expr ) => ( ) ; ( $ t : ident $ var : ident $ count : expr ; $ ( $ inner_t : ident $ inner_var : ident $ inner_count : expr ) ;* ) => { impl_from_fragments_for_tuples ! ( $ ( $ inner_t $ inner_var $ inner_count ) ;* ) ; impl <$ t : FromFragments , $ ( $ inner_t : FromFragments ) ,*> FromFragments for ( $ t , $ ( $ inner_t ) ,* ) { fn fragments_count ( ) -> usize { let mut n = <$ t >:: fragments_count ( ) ; $ ( n += <$ inner_t >:: fragments_count ( ) ; ) * n } # [ allow ( unused_assignments ) ] fn from_fragments ( fragments : & [ & str ] ) -> Result < ( $ t , $ ( $ inner_t ) ,* ) , String > { let mut start = 0 ; let $ var = <$ t >:: from_fragments ( & fragments [ start .. start +<$ t >:: fragments_count ( ) ] ) ?; start += <$ t >:: fragments_count ( ) ; $ ( let $ inner_var = <$ inner_t >:: from_fragments ( & fragments [ start .. start +<$ inner_t >:: fragments_count ( ) ] ) ?; start += <$ inner_t >:: fragments_count ( ) ; ) * Ok ( ( $ var , $ ( $ inner_var ) ,* ) ) } } } }
impl_from_fragments_for_tuples ! ( T4 x4 4 ; T3 x3 3 ; T2 x2 2 ; T1 x1 1 ) ;
#[macro_export]
macro_rules ! read { ( ) => { let mut line = String :: new ( ) ; std :: io :: stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; } ; ( $ pat : pat = $ t : ty ) => { let mut line = String :: new ( ) ; std :: io :: stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let $ pat = <$ t >:: from_line ( & line ) . unwrap ( ) ; } ; ( $ ( $ pat : pat = $ t : ty ) ,+ ) => { read ! ( ( $ ( $ pat ) ,* ) = ( $ ( $ t ) ,* ) ) ; } ; }
pub fn read<T: FromLine>() -> T {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    T::from_line(&line).unwrap()
}
#[macro_export]
macro_rules ! readls { ( $ ( $ pat : pat = $ t : ty ) ,+ ) => { $ ( read ! ( $ pat = $ t ) ; ) * } }
pub fn read_vec<T: FromLine>() -> Vec<T> {
    use std::io::{self, BufRead};
    let stdin = io::stdin();
    let result = stdin
        .lock()
        .lines()
        .map(|line_result| {
            let line = line_result.expect("read from stdin failed");
            T::from_line(&line).unwrap()
        }).collect();
    result
}
#[macro_export]
macro_rules ! read_loop { ( $ pat : pat = $ t : ty ; $ block : block ) => { use std :: io :: BufRead ; let stdin = std :: io :: stdin ( ) ; for line in stdin . lock ( ) . lines ( ) { let line = line . expect ( "read from stdin failed" ) ; let $ pat = <$ t >:: from_line ( & line ) . unwrap ( ) ; $ block } } ; ( $ ( $ pat : pat = $ t : ty ) ,* ; $ block : block ) => { read_loop ! ( ( $ ( $ pat ) ,* ) = ( $ ( $ t ) ,* ) ; $ block ) ; } }
#[macro_export]
macro_rules ! readn_loop { ( $ n : expr ; $ pat : pat = $ t : ty ; $ block : block ) => { use std :: io :: BufRead ; let stdin = std :: io :: stdin ( ) ; { let lock = stdin . lock ( ) ; for _ in 0 ..$ n { let line = String :: new ( ) ; lock . read_line ( & mut line ) . expect ( "read from stdin failed" ) ; let $ pat = <$ t >:: from_line ( & line ) . unwrap ( ) ; $ block } } } ; ( $ n : expr ; $ ( $ pat : pat = $ t : ty ) ,* ; $ block : block ) => { read_times_loop ! ( $ n ; ( $ ( $ pat ) ,* ) = ( $ ( $ t ) ,* ) ; $ block ) ; } }
trait ReadExt<T> {
    fn read(&self) -> T;
}
impl<'a, T: FromFragments> ReadExt<T> for [&'a str] {
    fn read(&self) -> T {
        T::from_fragments(self).unwrap()
    }
}
impl<'a, T: FromFragments> ReadExt<T> for &'a str {
    fn read(&self) -> T {
        T::from_fragments(&[self]).unwrap()
    }
}
#[macro_export]
macro_rules! readable {
    ( $ t : ty , $ fragments_count : expr , |$ fragments : ident | $ from_fragments : expr ) => {
        impl FromFragments for $t {
            fn fragments_count() -> usize {
                $fragments_count
            }
            fn from_fragments($fragments: &[&str]) -> Result<Self, String> {
                Ok($from_fragments)
            }
        }
    };
}

trait RichInt {
    fn abs_diff(self, rhs: Self) -> Self;
    fn mod_euc(self, rhs: Self) -> Self;
}
macro_rules ! impl_rich_int { ( $ ( $ t : ty ) * ) => { $ ( impl RichInt for $ t { fn abs_diff ( self , rhs : $ t ) -> $ t { if self < rhs { rhs - self } else { self - rhs } } # [ allow ( unused_comparisons ) ] fn mod_euc ( self , rhs : $ t ) -> $ t { let r = self % rhs ; if r < 0 { if rhs < 0 { r - rhs } else { r + rhs } } else { r } } } ) * } }
impl_rich_int ! ( u8 u16 u32 u64 usize i8 i16 i32 i64 isize ) ;
pub trait RichUInt {
    fn ceil_div(self, rhs: Self) -> Self;
    fn round_div(self, rhs: Self) -> Self;
}
macro_rules ! impl_rich_uint { ( $ ( $ t : ty ) * ) => { $ ( impl RichUInt for $ t { fn ceil_div ( self , rhs : $ t ) -> $ t { ( self + rhs - 1 ) / rhs } fn round_div ( self , rhs : $ t ) -> $ t { ( self + rhs / 2 - 1 ) / rhs } } ) * } }
impl_rich_uint ! ( u8 u16 u32 u64 ) ;

use std::cmp::{Ord, Ordering};
#[derive(Clone, Copy, PartialEq, Eq)]
struct Reverse<T>(T);
impl<T: PartialOrd> PartialOrd for Reverse<T> {
    fn partial_cmp(&self, other: &Reverse<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}
impl<T: Ord> Ord for Reverse<T> {
    fn cmp(&self, other: &Reverse<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}
trait SortDesc<T> {
    fn sort_desc(&mut self)
    where
        T: Ord;
    fn sort_desc_by_key<K: Ord, F: FnMut(&T) -> K>(&mut self, f: F);
}
impl<T> SortDesc<T> for [T] {
    fn sort_desc(&mut self)
    where
        T: Ord,
    {
        self.sort();
        self.reverse();
    }
    fn sort_desc_by_key<K: Ord, F: FnMut(&T) -> K>(&mut self, mut f: F) {
        self.sort_by_key(|x| Reverse(f(x)));
    }
}
#[derive(PartialEq, PartialOrd)]
struct Total<T: PartialOrd + PartialEq>(T);
impl<T: PartialOrd + PartialEq> Eq for Total<T> {}
impl<T: PartialOrd + PartialEq> Ord for Total<T> {
    fn cmp(&self, other: &Self) -> Ordering {
        self.partial_cmp(other).unwrap()
    }
}

use std::cmp;

#[derive(Clone, Copy, Debug)]
struct Problem {
    score: u32,
    count: u32,
    complete: u32
}

impl Problem {
    fn complete_score(self) -> u32 {
        self.score * self.count + self.complete
    }

    fn halfway_score_max(self) -> u32 {
        self.score * (self.count - 1)
    }
}

fn calc_halfway(score_rest: u32, mut problems: Vec<Problem>) -> u32 {
    problems.sort_desc_by_key(|&p| p.score);
    let mut score = 0;
    let mut count = 0;
    for p in problems {
        if score + p.halfway_score_max() >= score_rest {
            return count + score_rest.ceil_div(p.score);
        }
        score += p.halfway_score_max();
        count += p.count - 1;
    }
    return u32::max_value() / 2;
}

fn solve(g: u32, problems: &[Problem], complete: Vec<Problem>, halfway: Vec<Problem>) -> u32 {
    match problems.split_first() {
        None => {
            let score: u32 = complete.iter().map(|p| p.complete_score()).sum();
            let count: u32 = complete.iter().map(|p| p.count).sum();
            if score >= g {
                count
            } else {
                count + calc_halfway(g - score, halfway)
            }
        },
        Some((&first, rest)) => {
            let mut next_complete = complete.clone();
            next_complete.push(first);
            let mut next_halfway = halfway.clone();
            next_halfway.push(first);
            cmp::min(solve(g, rest, complete, next_halfway),
                     solve(g, rest, next_complete, halfway))
        }
    }
}

fn main() {
    read!(_ = (), g = u32);
    let problems: Vec<Problem> = read_vec::<(u32, u32)>()
        .into_iter()
        .zip(1..)
        .map(|((count, complete), i)| {
            Problem { score: i * 100, count: count, complete: complete }
        }).collect();

    println!("{}", solve(g, &problems, Vec::new(), Vec::new()));
}