Logo
(追記) (追記ここまで)

6024번 - Covering the Corral 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB83331730.357%

문제

The cows are so modest they want Farmer John to install covers around the circular corral where they occasionally gather. The corral has circumference C (1 <= C <= 1,000,000,000), and FJ can choose from a set of M (1 <= M <= 100,000) covers that have fixed starting points and sizes. At least one set of covers can surround the entire corral.

Cover i can be installed at integer location x_i (distance from starting point around corral) (0 <= x_i < C) and has integer length l_i (1 <= l_i <= C).

FJ wants to minimize the number of segments he must install. What is the minimum number of segments required to cover the entire circumference of the corral?

Consider a corral of circumference 5, shown below as a pair of connected line segments where both '0's are the same point on the corral (as are both 1's, 2's, and 3's).

Three potential covering segments are available for installation:

 Start Length
 i x_i l_i
 1 0 1 
 2 1 2 
 3 3 3 
 0 1 2 3 4 0 1 2 3 ... 
corral: +---+---+---+---+--:+---+---+---+- ...
 11111 1111
 22222222 22222222
 333333333333
 |..................|

As shown, installing segments 2 and 3 cover an extent of (at least) five units around the circumference. FJ has no trouble with the overlap, so don't worry about that.

입력

  • Line 1: Two space-separated integers: C and M
  • Lines 2..M+1: Line i+1 contains two space-separated integers: x_i and l_i

출력

  • Line 1: A single integer that is the minimum number of segments required to cover all segments of the circumference of the corral

제한

예제 입력 1

5 3
0 1
1 2
3 3

예제 출력 1

2

힌트

출처

Olympiad > USA Computing Olympiad > 2009-2010 Season > USACO February 2010 Contest > Gold 1번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /