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 Java8 (OpenJDK 1.8.0) (judge verdict: Accepted)


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		//		new Main().solveB();
		/**
		 * remaining problem C
		 */
		//		new Main().solveC();
		new Main().solveC2();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numRating = 0;

		try {
			scanner = new Scanner(System.in);
			numRating = scanner.nextInt();

			if (numRating < 1200) {
				System.out.println("ABC");
			} else if (numRating < 2800) {
				System.out.println("ARC");
			} else {
				System.out.println("AGC");
			}

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		String strS = "";

		try {
			scanner = new Scanner(System.in);
			strS = scanner.next();

			if (strS.charAt(0) != 'A') {
				System.out.println("WA");
				return;
			}
			int res = 0;
			int wkIndex = 0;
			for (int i = 2; i < strS.length() - 1; i++) {
				if (strS.charAt(i) == 'C') {
					res++;
					wkIndex = i;
				}
			}
			if (res != 1) {
				System.out.println("WA");
				return;
			}
			for (int i = 0; i < strS.length(); i++) {
				if (i != 0 && i != wkIndex && !Character.isLowerCase(strS.charAt(i))) {
					System.out.println("WA");
					return;
				}
			}
			System.out.println("AC");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private long solveCsaiki(long currentG, int currentI, long[][] wk, long numG) {

		if (currentI < 0) {
			return currentG;
		}
		if (wk[currentI][1] <= 0) {
			return solveCsaiki(currentG, currentI + 1, wk, numG);
		}

		long currentG2 = currentG;
		long count1 = 0;
		while (currentG2 <= numG && wk[currentI][1] > 0) {
			currentG2 -= wk[currentI][0];
			wk[currentI][1]--;
			count1++;
		}
		if (currentG2 > 0) {
			currentG2 -= wk[currentI][2];
		}
		long count2 = solveCsaiki(currentG, currentI, wk, numG);
		return Math.min(count1, count2);

	}

	private void solveC() {
		Scanner scanner = null;
		int numD = 0;
		long numG = 0;

		try {
			scanner = new Scanner(System.in);
			numD = scanner.nextInt();
			numG = scanner.nextInt();
			long[][] wk = new long[numD][7];

			for (int i = 0; i < wk.length; i++) {
				wk[i][0] = (i + 1) * 100;//単価
				wk[i][1] = scanner.nextLong();//残数
				wk[i][2] = scanner.nextLong();//コンプリートボーナス
				wk[i][3] = (wk[i][0] * wk[i][1]);//総額
				wk[i][4] = wk[i][3] + wk[i][2];//コンプリート総額
				wk[i][5] = wk[i][4] / wk[i][1];//コンプリート単価
				wk[i][6] = 0;//使った回数
			}

			long res = 0;
			for (int i = 0; i < wk.length; i++) {
				res += wk[i][6];
			}
			System.out.println(solveCsaiki(numG, 0, wk, numG));

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	public void solveC2() {
		Scanner sc = null;
		int n = 0;
		int goal = 0;
		int[][] arr;
		try {
			sc = new Scanner(System.in);
			n = sc.nextInt() /* <= 10 */;
			goal = sc.nextInt();
			arr = new int[n][5];
			for (int i = 0; i < n; i++) {
				arr[i][0] = (i + 1) * 100; // for which score problem
				arr[i][1] = sc.nextInt(); // how many
				arr[i][2] = sc.nextInt(); // bonus
				arr[i][3] = arr[i][0] * arr[i][1] + arr[i][2]; // total
			}

			//残数チェック
			boolean[] left = new boolean[n];
			for (int i = 0; i < n; i++) {
				left[i] = true;
			}
			int min = Integer.MAX_VALUE;
			for (int i = 0; i < n; i++) {
				int count = 0;
				int score = 0;
				min = Math.min(rec(count, score, left, i, arr, goal), min);
			}
			System.out.println(min);
		} finally {
			if (sc != null) {
				sc.close();
			}
		}
	}

	public int rec(int count, int score, boolean[] left, int idx, int[][] arr, int goal) {
		if (score >= goal) {
			return count;
		}

		//とりあえず、ﾁｮｯﾄずつ引く
		for (int i = 0; i < arr[idx][1]; i++) {
			score += arr[idx][0];
			count++;
			//途中でgoalを超えたらreturn
			if (score >= goal) {
				return count;
			}
		}
		score += arr[idx][2];
		if (score >= goal) {
			return count;
		}

		int min = Integer.MAX_VALUE;
		left[idx] = false;
		for (int i = 0; i < left.length; i++) {
			if (left[i]) {
				min = Math.min(rec(count, score, left, i, arr, goal), min);
			}
		}
		left[idx] = true;
		return min;
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}