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

28226번 - Simplification 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB35181546.875%

문제

Amin records the price of his stock every now and then as a data point (ti, pi) in his notebook, where pi is the price of his stock at day ti. The sequence of these data points represents a piecewise-linear function F displaying the history of prices over a period of time. Indeed, F connects every pair of consecutive points by a straight line segment. If the price is not recorded for some day t, F(t) can be used as an estimate instead.

His collected data is getting larger and larger as he has been tracking the price of his stock over a long period of time. Therefore, he has decided to reduce his data by throwing away some of his recoded data points and constructing a new piecewise-linear function F′ with the remaining points. F′ is a so-called “simplification” of F. Amin wants to create the simplification in such a way that F′ is a good approximation for F. To this end, he has defined an error measure as follows.

Let F be defined over a strictly increasing sequence L = ⟨t1, ..., tn⟩ of days, and F′ be defined over a subsequence L′ = ⟨t′1 , ..., t′m⟩ of L, where t′1 = t1, t′m = tn, and F′(t′i ) = F(t′i ) for 1 ⩽ i ⩽ m. (We call m the size of F′.) The error of F′ is defined as the maximum of |F′(tk) − F(tk)| for all 1 ⩽ k ⩽ n. For example, in the following figure, we have 6 data points, labeled 1 through 6, whose coordinates are the same as those presented in the second sample input, and F′ is a simplification of F of size 3 with data points 1, 4 and 6. In this figure, F is depicted by solid lines, and F′ by dashed lines. The error measure for F′ is realized by the vertical distance of point 2 to F′ .

Amin’s goal is to minimize the size of F′, while the error of F′ is bounded by a given value δ.

입력

The first line of input contains a positive integer n (2 ⩽ n ⩽ 2000) that shows the size of F. Each of the next n lines contains two integers ti, pi (1 ⩽ ti, pi ⩽ 106), where pi is the price of the stock at day ti. The last line contains the error limit δ which is a non-negative integer at most 106.

출력

In the output, print the minimum possible size of F′.

제한

예제 입력 1

3
1 10
3 100
10 20
90

예제 출력 1

2

예제 입력 2

6
10 10
20 20
35 14
50 20
60 10
70 10
8

예제 출력 2

3

힌트

출처

ICPC > Regionals > Asia West Continent > Iran > 2022 ICPC Asia Tehran Regional Contest C번

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

출처

대학교 대회

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

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