QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 256 MB مجموع النقاط: 100

#21272. Cow Coupons

الإحصائيات

Farmer John needs new cows! There are $N$ cows for sale $1 \le N \le 50,000$, and FJ has to spend no more than his budget of $M$ units of money $1 \le M \le 10^{14}$. Cow $i$ costs $P_{i}$ money $1 \le P_{i} \le 10^9$, but FJ has $K$ coupons $1 \le K \le N$, and when he uses a coupon on cow $i$, the cow costs $C_{i}$ instead $1 \le C_{i} \le P_{i}$. FJ can only use one coupon per cow, of course.

What is the maximum number of cows FJ can afford?

Input

  • Line 1: Three space-separated integers: $N$, $K$, and $M$.
  • Lines $2..N+1$: Line $i+1$ contains two integers: $P_{i}$ and $C_{i}$.

Output

  • Line 1: A single integer, the maximum number of cows FJ can afford.

Examples

Input 1

4 1 7
3 2
2 2
8 1
4 3

Output 1

3

FJ has 4 cows, 1 coupon, and a budget of 7.

FJ uses the coupon on cow 3 and buys cows 1, 2, and 3, for a total cost of 3 + 2 + 1 = 6.

Problem credits: Neal Wu and Mark Gordon, 2012

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.