#Lutece0552. Cow Coupons

Cow Coupons

Migrated from Lutece 552 Cow Coupons

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

Farmer John needs new cows! There are NN cows for sale (1N50,0001 \leq N \leq 50,000), and FJ has to spend no more than his budget of MM units of money (1M10141 \leq M \leq 10^{14}). Cow ii costs PiP_i money (1Pi1091 \leq P_i \leq 10^9), but FJ has KK coupons (1KN1 \leq K \leq N), and when he uses a coupon on cow ii, the cow costs CiC_i instead (1CiPi1 \leq C_i \leq P_i). FJ can only use one coupon per cow, of course.

Input

  • Line 11: Three space-separated integers: NN, KK, and MM.
  • Lines 2N+12\cdots N+1: Line i+1i+1 contains two integers: PiP_i and CiC_i.

Output

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

Samples

4 1 7
3 2
2 2
8 1
4 3
3

Note

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

Resources

USACO Feb 2012