아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Waterfront

시간 제한2초메모리 제한1024 MB

요약
M일 동안 매일 자란 뒤 하루 최대 k번, 한 번에 x센티미터씩 자를 수 있을 때 가장 높은 나무의 최소 높이를 구한다.
난이도

보통10점 중 7점

유형
이분 탐색, 그리디
정답자
아직 제출이 없습니다

문제

On the waterfront of the Prahova River, the Mayor of Ploieşti planted a row of NN ornamental tree shrubs of various varieties, each tree shrub ii initially having the height height\[i]height\[i], 1≤i≤N1 ≤ i ≤ N. Depending on the soil in which it is planted and the weather, the shrub ii grows daily with height dailyGrowth\[i]dailyGrowth\[i].

Every day the town hall gardener adjusts the height of the tree shrubs by cutting them with scissors. However, the gardener is limited by the quality of the scissors. Thus, with one cut they can cut off exactly xx centimeters from the height of a shrub tree if the height is at least xx centimeters (note that the tree shrub may reach height 00 after a cut). In order not to get tired, the gardener can perform at most kk cuts in a day. The gardener can make several cuts on the same tree shrub in one day.

The mayor organizes an artistic event after MM days and wants to know what is the minimum possible height of the tallest tree shrub after the MM days.

Note! Every day, the trees grow first, and then the cuts are done.

입력

The first line contains NN, MM, kk and xx. Of the following NN lines, the iith contains height\[i]height\[i] and dailyGrowth\[i]dailyGrowth\[i], separated by a single space.

출력

Output a non-negative integer, representing the minimum height of the tallest tree shrub, after the MM days.

제한

  • 1≤k≤1,0001 ≤ k ≤ 1\\,000
  • 1≤x≤10,0001 ≤ x ≤ 10\\,000
  • 0≤height\[i]≤10,0000 ≤ height\[i] ≤ 10\\,000
  • 0≤dailyGrowth\[i]≤10,0000 ≤ dailyGrowth\[i] ≤ 10\\,000

힌트

The gardener cuts the trees in 33 days, making 44 cuts every day. At each cut they can remove 33 centimeters from the height of one tree. The following table summarises the optimal way to make the cuts.

DayTreeOperations
11112→+57→−342 \xrightarrow{+5} 7 \xrightarrow{-3} 4
223→+253 \xrightarrow{+2} 5
330→+440 \xrightarrow{+4} 4
442→+810→−37→−34→−312 \xrightarrow{+8} 10 \xrightarrow{-3} 7 \xrightarrow{-3} 4 \xrightarrow{-3} 1
22114 →+59 →−36 →−334 \xrightarrow{+5} 9 \xrightarrow{-3} 6 \xrightarrow{-3} 3
225 →+275 \xrightarrow{+2} 7
334 →+484 \xrightarrow{+4} 8
441 →+89 →−36 →−331 \xrightarrow{+8} 9 \xrightarrow{-3} 6 \xrightarrow{-3} 3
33113 →+583 \xrightarrow{+5} 8
227 →+29 →−367 \xrightarrow{+2} 9 \xrightarrow{-3} 6
338 →+412 →−39 →−368 \xrightarrow{+4} 12 \xrightarrow{-3} 9 \xrightarrow{-3} 6
443 →+811 →−383 \xrightarrow{+8} 11 \xrightarrow{-3} 8

예제1

  1. 예제 1

    입력
    4 3 4 3
    2 5
    3 2
    0 4
    2 8
    
    예상 출력
    8