#abc219d. D - Strange Lunchbox

D - Strange Lunchbox

Score : 400400 points

问题描述

一家商店出售NN种便当,每种便当各一个。 对于每种i=1,2,,Ni = 1, 2, \ldots, N,第ii种便当中含有AiA_i个章鱼烧(takoyaki)和BiB_i个鲷鱼烧(taiyaki)。

高桥想要吃至少XX个章鱼烧和至少YY个鲷鱼烧。
判断是否有可能通过购买一定数量的便当来获得至少XX个章鱼烧和至少YY个鲷鱼烧。如果可能,找出高桥必须购买的最少便当数量以获取这些食物。

请注意,每种便当仅库存一个;你不能购买同一种类的两个或更多的便当。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

A shop sells NN kinds of lunchboxes, one for each kind.
For each i=1,2,,Ni = 1, 2, \ldots, N, the ii-th kind of lunchbox contains AiA_i takoyaki (octopus balls) and BiB_i taiyaki (fish-shaped cakes).

Takahashi wants to eat XX or more takoyaki and YY or more taiyaki.
Determine whether it is possible to buy some number of lunchboxes to get at least XX takoyaki and at least YY taiyaki. If it is possible, find the minimum number of lunchboxes that Takahashi must buy to get them.

Note that just one lunchbox is in stock for each kind; you cannot buy two or more lunchboxes of the same kind.

Constraints

  • 1N3001 \leq N \leq 300
  • 1X,Y3001 \leq X, Y \leq 300
  • 1Ai,Bi3001 \leq A_i, B_i \leq 300
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

XX YY

A1A_1 B1B_1

A2A_2 B2B_2

\vdots

ANA_N BNB_N

Output

If Takahashi cannot get at least XX takoyaki and at least YY taiyaki, print 1-1; otherwise, print the minimum number of lunchboxes that he must buy to get them.

Sample Input 1

3
5 6
2 1
3 4
2 3

Sample Output 1

2

He wants to eat 55 or more takoyaki and 66 or more taiyaki.
Buying the second and third lunchboxes will get him 3+2=53 + 2 = 5 taiyaki and 4+3=74 + 3 = 7 taiyaki.

Sample Input 2

3
8 8
3 4
2 3
2 1

Sample Output 2

-1

Even if he is to buy every lunchbox, it is impossible to get at least 88 takoyaki and at least 88 taiyaki.
Thus, print 1-1.

update @ 2024/3/10 09:41:30