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

8042번 - Where to Build a Brewery? 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 512 MB53241951.351%

문제

The dwellers of the island Abstinence are very fond of alkoholfree beer. Hitherto alkohol-free beer was imported from Poland, but this year one of the cities on Abstinence is going to build a brewery. All the cities of this island lie on the coast and are connected by a highway running around the island along its shore. The investor building the brewery collected information about the demand for beer, i.e. how many tanks of beer are needed daily in each city. He has also a table of distances between cities. The cost of transporting one tank is 1 thaler per mile. A daily cost of transport is the amount of money, which has to be spent on transporting a necessary number of tanks of beer from the brewery to each city. The daily cost depends on the location of the brewery. The investor wants to find a location that minimizes the daily cost.

Write a program which

  • reads the number of cities, distances between them and daily requests for beer,
  • computes the minimal daily cost of transport,
  • writes the result to the standard output.

입력

In the first line of the standard input there is one integer n - the number of cities, 5 ≤ n ≤ 10,000. (We assume that cities are numbered along the highway, so that the neighbouring cities have subsequent numbers. Cities 1 and n are neighbours too.) In each of the following n lines there are two non-negative numbers separated by a single space. Numbers z^i, d^i written in the line (i+1) are respectively the demand for beer in the city i and the distance (in miles) from city i to the next city on the highway. The entire length of the highway is not greater than 1,000,000 miles. The demand for beer in each city is not greater than 1,000 tanks.

출력

Your program should write in the first and only line of the standard output exactly one integer equal to the minimal daily cost of transport.

제한

예제 입력 1

6
1 2
2 3
1 2
5 2
1 10
2 3

예제 출력 1

41

힌트

출처

Olympiad > Polish Olympiad in Informatics > POI 1999/2000 > Stage 1 1번

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

출처

대학교 대회

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

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