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)

#![allow(unused)]

use std::{cell, cmp, collections, fmt, iter, ops};

use cell::{Cell, RefCell};
use cmp::Ordering;
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use fmt::{Debug, Display};
use ops::{
    Add, AddAssign, Deref, DerefMut, Div, DivAssign, Mul, MulAssign, Neg, Not, Sub, SubAssign,
};



// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[macro_export]
macro_rules! input {
    (src = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        _input_inner!(iter, $($r)*)
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        input!(src = s, $($r)*)
    };
}

#[macro_export]
macro_rules! inputln {
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        _input_inner!(iter, $($r)*)
    };
}

#[macro_export]
macro_rules! _input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = _parse_value!($iter, $t);
        _input_inner!($iter $($r)*)
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = _parse_value!($iter, $t);
        _input_inner!($iter $($r)*)
    };
}

#[macro_export]
macro_rules! _parse_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(_parse_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| _parse_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        _parse_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        _parse_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().expect("No item left").parse::<$t>().expect("Parse error")
    };
}

#[cfg(feature = "debug")]
#[macro_export]
macro_rules! d {
    ($val:expr) => {
        match $val {
            tmp => {
                eprintln!("[{}] {} = {:#?}", line!(), stringify!($val), &tmp);
                tmp
            }
        }
    };
}

#[cfg(not(feature = "debug"))]
#[macro_export]
macro_rules! d {
    ($val:expr) => {
        $val
    };
}

/// ```
/// # use lib::*;
/// assert_eq!(vmin!(0, 1), 0);
/// assert_eq!(vmin!(3, 2, 1), 1);
/// ```
#[macro_export]
macro_rules! vmin {
    ($x:expr, $y:expr) => { std::cmp::min($x, $y) };
    ($x:expr, $($args:expr),*) => { std::cmp::min($x, vmin!($($args),*)) };
}

/// ```
/// # use lib::*;
/// assert_eq!(vmax!(0, 1), 1);
/// assert_eq!(vmax!(3, 2, 1), 3);
/// ```
#[macro_export]
macro_rules! vmax {
    ($x:expr, $y:expr) => { std::cmp::max($x, $y) };
    ($x:expr, $($args:expr),*) => { std::cmp::max($x, vmax!($($args),*)) };
}

/// ```
/// # use lib::*;
/// let v = vec![2, 1, 0, 3];
/// assert_eq!(prefix!(v).collect::<Vec<i32>>(), vec![0, 2, 3, 3, 6]);
/// ```
#[macro_export]
macro_rules! prefix {
    ($iter: expr) => {{
        use std::iter;

        iter::once(Default::default())
            .chain($iter.into_iter())
            .scan(Default::default(), |acc, x| {
                *acc += x;
                Some(*acc)
            })
    }};
}

pub mod num {
    /// ```
    /// # use lib::*;
    /// assert_eq!(num::gcd(2, 5), 1);
    /// assert_eq!(num::gcd(4, 6), 2);
    /// ```
    pub fn gcd(a: u64, b: u64) -> u64 {
        if b == 0 {
            a
        } else {
            gcd(b, a % b)
        }
    }

    /// ```
    /// # use lib::*;
    /// assert_eq!(num::gcd_slice(&[3]), 3);
    /// assert_eq!(num::gcd_slice(&[2, 5]), 1);
    /// assert_eq!(num::gcd_slice(&[4, 6, 8]), 2);
    /// ```
    pub fn gcd_slice(a: &[u64]) -> u64 {
        a.iter().fold(a[0], |a, b| gcd(a, *b))
    }

    /// ```
    /// # use lib::*;
    /// assert_eq!(num::lcm(2, 5), 10);
    /// assert_eq!(num::lcm(4, 6), 12);
    /// ```
    pub fn lcm(a: u64, b: u64) -> u64 {
        a * b / gcd(a, b)
    }

    /// ```
    /// # use lib::*;
    /// assert_eq!(num::lcm_slice(&[3]), 3);
    /// assert_eq!(num::lcm_slice(&[2, 5]), 10);
    /// assert_eq!(num::lcm_slice(&[4, 6, 8]), 24);
    /// ```
    pub fn lcm_slice(a: &[u64]) -> u64 {
        a.iter().fold(a[0], |a, b| lcm(a, *b))
    }
}

pub mod bits {
    /// ```
    /// # use lib::*;
    /// assert!(!bits::is_high(0b0100, 0));
    /// assert!(bits::is_high(0b0100, 2));
    /// ```
    pub fn is_high(bits: u64, pos: usize) -> bool {
        bits & (1 << pos as u64) != 0
    }

    /// ```
    /// # use lib::*;
    /// assert_eq!(bits::len(0b1010), 4);
    /// assert_eq!(bits::len(0b1), 1);
    /// assert_eq!(bits::len(0b0), 0);
    /// ```
    pub fn len(bits: u64) -> usize {
        for b in 0..64 {
            if is_high(bits, 63 - b) {
                return (64 - b) as usize;
            }
        }

        return 0;
    }
}

#[derive(Clone, Debug)]
pub struct UnionFind {
    parent: Vec<usize>,
    size: Vec<usize>,
    depth: Vec<usize>,
}

/// ```
/// # use lib::*;
/// let mut uf = UnionFind::new(4);
/// assert_eq!(uf.size(0), 1);
/// assert_eq!(uf.find(0), 0);
///
/// uf.union(0, 1);
/// assert!(uf.same(0, 1));
/// assert!(uf.find(0) == 0 || uf.find(0) == 1);
/// assert_eq!(uf.size(0), 2);
///
/// uf.union(1, 2);
/// assert!(uf.same(0, 2));
/// assert!(uf.find(0) == 0 || uf.find(0) == 1); // not 2
/// assert_eq!(uf.size(0), 3);
/// ```
impl UnionFind {
    pub fn new(capacity: usize) -> Self {
        UnionFind {
            parent: (0..capacity).collect(),
            size: vec![1; capacity],
            depth: vec![0; capacity],
        }
    }

    pub fn size(&mut self, a: usize) -> usize {
        let p = self.find(a);
        self.size[p]
    }

    pub fn find(&mut self, a: usize) -> usize {
        if self.parent[a] == a {
            a
        } else {
            let p = self.parent[a];
            self.parent[a] = self.find(p);
            self.parent[a]
        }
    }

    pub fn same(&mut self, a: usize, b: usize) -> bool {
        self.find(a) == self.find(b)
    }

    pub fn union(&mut self, a: usize, b: usize) {
        let a = self.find(a);
        let b = self.find(b);
        if a == b {
            return;
        }

        if self.depth[a] < self.depth[b] {
            self.parent[a] = b;
            self.size[b] += self.size[a];
        } else {
            self.parent[b] = a;
            self.size[a] += self.size[b];

            if self.depth[a] == self.depth[b] {
                self.depth[a] += 1;
            }
        }
    }
}

// std::cmp::Reverse is stable since 1.19
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
struct Rev<T>(T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Self) -> Ordering {
        other.0.cmp(&self.0)
    }
}

/// ```
/// # use lib::*;
/// use std::collections::BinaryHeap;
///
/// let heap = [1, 0, 2, 3].iter().cloned().collect::<BinaryHeap<_>>();
/// let sorted = heap.into_iter_sorted().collect::<Vec<_>>();;
/// assert_eq!(sorted, vec![3, 2, 1, 0]);
/// ```
// BinaryHeap::iter() iterates values in arbitrary order.
pub struct IterSorted<T: Ord> {
    heap: BinaryHeap<T>,
}

pub trait IntoIteratorSorted {
    type Item;
    type IntoIterSorted: Iterator<Item = Self::Item>;

    fn into_iter_sorted(self) -> Self::IntoIterSorted;
}

impl<T: Ord> IntoIteratorSorted for BinaryHeap<T> {
    type Item = T;
    type IntoIterSorted = IterSorted<T>;

    fn into_iter_sorted(self) -> IterSorted<T> {
        IterSorted { heap: self }
    }
}

impl<T: Ord> Iterator for IterSorted<T> {
    type Item = T;

    fn next(&mut self) -> Option<Self::Item> {
        self.heap.pop()
    }
}

fn main() {
    input!(
        difficulty_max: usize,
        target_score: u64,
        problems: [(usize, u64); difficulty_max],
    );

    let ans = (0..(1 << difficulty_max))
        .filter_map(|solve_all| {
            let mut solves = 0;
            let mut score = 0;

            for b in 0..difficulty_max {
                if bits::is_high(solve_all, b) {
                    solves += problems[b].0;
                    score += 100 * (b + 1) as u64 * problems[b].0 as u64 + problems[b].1;
                }
            }

            'for_difficulty: for b in (0..difficulty_max)
                .rev()
                .filter(|b| !bits::is_high(solve_all, *b))
            {
                for _ in 0..(problems[b].0 - 1) {
                    if score >= target_score {
                        break 'for_difficulty;
                    }

                    solves += 1;
                    score += 100 * (b + 1) as u64;
                }
            }

            if score >= target_score {
                Some(solves)
            } else {
                None
            }
        })
        .min()
        .unwrap();

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

#[cfg(test)]
mod tests {
    #[allow(unused)]
    use super::*;

    #[test]
    fn test() {
        //
    }
}