PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GD0000140. Phản ví dụ cho tham lam theo tỉ lệ (0/1 Knapsack Ratio Counterexample)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Phản ví dụ cho tham lam theo tỉ lệ (0/1 Knapsack Ratio Counterexample)

0/1 Knapsack Ratio Counterexample

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem Statement

You have nn items of positive integer weights wiw_i and values viv_i, and a 0/1 knapsack with capacity WW. Consider a hypothetical ratio-greedy algorithm: sort items by decreasing ratio vi/wiv_i/w_i, breaking ties by smaller original index, then accept an item if it fits and skip it otherwise. Output its value, the true optimal 0/1 knapsack value, and whether the ratio-greedy rule fails for the given instance.

Input

The first line contains n,Wn,W. Each of the next nn lines contains wi,viw_i,v_i.

Output

Print the greedy value and the true optimal value on the first line. On the second line print YES if greedy is worse than optimal, otherwise NO.

Subtasks

  • Subtask 1 (20 points): 1≤n≤81\le n\le 8; 1≤W≤10001\le W\le1000; 1≤wi≤W1\le w_i\le W; 1≤vi≤1041\le v_i\le10^4.
  • Subtask 2 (30 points): 1≤n≤301\le n\le 30; 1≤W≤10001\le W\le1000; 1≤wi≤W1\le w_i\le W; 1≤vi≤1041\le v_i\le10^4.
  • Subtask 3 (50 points): 1≤n≤1001\le n\le 100; 1≤W≤10001\le W\le1000; 1≤wi≤W1\le w_i\le W; 1≤vi≤1041\le v_i\le10^4.

Examples

Input

3 50
10 60
20 100
30 120

Output

160 220
YES

Explanation

Ratio-greedy chooses item 11 (weight 1010, value 6060) and item 22 (weight 2020, value 100100), totaling 160160. The optimal subset is items 22 and 33, weight 5050, value 220220. Therefore the rule fails, and YES is printed.