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

#GD0000082. Tưới cỏ (Watering Grass)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Tưới cỏ (Watering Grass)

Watering Grass

Source: Kattis

Version: Phuoc Hung OJ Extended

Problem Statement

A rectangular lawn has length LL and width WW. There are nn sprinklers on its longitudinal centerline; sprinkler ii is at horizontal coordinate xix_i and covers a circle of radius rir_i. Find the minimum number of sprinklers whose combined coverage includes the entire rectangle, or -1 if impossible.

Input

The first line contains integers n,L,Wn,L,W. Each of the next nn lines contains integers xi,rix_i,r_i in meters.

Output

Print the minimum number of sprinklers, or -1 if full coverage is impossible.

Subtasks

  • Subtask 1 (20 points): 1≤n≤121\le n\le 12; 1≤L,W≤1041\le L,W\le10^4; 0≤xi≤L0\le x_i\le L; 1≤ri≤1041\le r_i\le10^4.
  • Subtask 2 (30 points): 1≤n≤10001\le n\le 1000; 1≤L,W≤1041\le L,W\le10^4; 0≤xi≤L0\le x_i\le L; 1≤ri≤1041\le r_i\le10^4.
  • Subtask 3 (50 points): 1≤n≤1041\le n\le10^4; 1≤L,W≤1041\le L,W\le10^4; 0≤xi≤L0\le x_i\le L; 1≤ri≤1041\le r_i\le10^4.

Examples

Input

3 10 2
3 5
9 3
6 1

Output

2

Explanation

The sprinkler at x=3x=3 covers the full strip horizontally from about −1.899-1.899 to 7.8997.899; the one at x=9x=9 covers from about 6.1726.172 to 11.82811.828. Their union covers [0,10][0,10], while neither sprinkler does so by itself. Two are necessary.