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

7052번 - Two sawmills 다국어

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

문제

There are n old trees planted along a road that goes from the top of a hill to its bottom. Local government decided to cut them down. In order not to waste wood each tree should be transported to a sawmill.

Trees can be transported only in one direction: downwards. There is a sawmill at the lower end of the road. Two additional sawmills can be built along the road. You have to decide where to build them, as to minimize the cost of transportation. The transportation costs one cent per meter, per kilogram of wood.

Write a program, that:

  • reads from the standard input the number of trees, their weights and locations,
  • calculates the minimum cost of transportation,
  • writes the result to the standard output.

입력

The first line of the input contains one integer n the number of trees (2 ≤ n ≤20 000). The trees are numbered 1, 2, ..., n, starting from the top of the hill and going downwards. Each of the following n lines contains two positive integers separated by single space. Line i + 1 contains: wi weight (in kilograms) of the i-th tree and di distance (in meters) between trees number i and i + 1, 1 ≤ wi ≤ 10 000, 0 ≤ di ≤ 10 000. The last of these numbers, dn, is the distance from the tree number n to the lower end of the road. It is guaranteed that the total cost of transporting all trees to the sawmill at the end of the road is less than 2 000 000 000 cents.

출력

The first and only line of output should contain one integer: the minimum cost of transportation.

제한

예제 입력 1

9
1 2
2 1
3 3
1 1
3 2
1 6
2 1
1 2
1 1

예제 출력 1

26

힌트

The figure shows the optimal location of sawmills for the example data.Trees are depicted as circles with weights given below. Sawmills aremarked black. The result is equal to:

1 · (2 + 1) + 2 · 1+1 · (1 + 2) + 3 · 2+2 · (1 + 2 + 1) + 1 · (2 + 1) + 1 · 1

출처

Olympiad > Central European Olympiad in Informatics > CEOI 2004 > Day 2 6번

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

출처

대학교 대회

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

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