아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Dirichlet

시간 제한2.5초메모리 제한512 MB

요약
최대 5종류 벽돌의 개수와 길이가 주어질 때, 모든 벽돌을 길이가 같은 N개 층으로 나눌 수 있는지 판정한다.
난이도

보통10점 중 7점

유형
동적 계획법, 비트 연산, 완전 탐색, 수학
정답자
아직 제출이 없습니다

문제

Four friends Johann, Peter, Gustav and Lejeune are planning to build a brick wall. They already decided it should be a parallelepiped with one decimeter width and NN decimeters height, but they are still not sure about its length. 

There were TT types of bricks available in the nearest store, and as they have no project of the wall, they simply bought c_ic\_i bricks of type ii for each ii from 11 to TT. A brick of type ii is a parallelepiped of size 1×1×l_i1 \times 1 \times l\_i decimeters.

Due to the stability issues, all of the bricks should be put horizontally. That means each brick will be used in only one level of the wall. To build a wall of height NN, one needs to form NN sets of bricks. Every set can contain arbitrary number of bricks of any type, but the total length of all bricks in any set should be equal among all the sets.

Now friends wonder, whether it is possible to build a wall using all bricks they bought in the store.

입력

The first line of the input contains two integers TT and NN --- the number of brick types and the desired height of the wall respectively (1≤T≤51 \leq T \leq 5, 1≤N≤101 \leq N \leq 10).

Then follow TT lines describing the types. The ii-th of these lines contains two integers c_ic\_i and l_il\_i --- the number of bricks of type ii bought by the friends and the length of a single brick of this type (1≤c_i≤641 \leq c\_i \leq 64, 1≤l_i≤1061 \leq l\_i \leq 10^6).

출력

If it is possible to build a wall without breaking any requirements, print "Yes" on a single line of the output. Otherwise, print "No".

힌트

In the first example, the only possible way to construct the wall is to make one level from the only brick of the first type and four bricks of the third type, and another level from all bricks of the second type and one brick of the third type.

Please note that the time limit is harsh. Some extra optimizations may be required to get the problem accepted.

예제3

  1. 예제 1

    입력
    3 2
    1 7
    2 5
    5 1
    
    예상 출력
    Yes
    
  2. 예제 2

    입력
    3 10
    2 14
    2 5
    1 1
    
    예상 출력
    No
    
  3. 예제 3

    입력
    3 2
    1 7
    2 5
    1 1
    
    예상 출력
    No