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

30436번 - Electronic Components 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 (추가 시간 없음) 1024 MB3213833.333%

문제

Sara is doing her summer internship at NCPC (Never Crashing Personal Computers). One day, a rare creature appeared in the office: an algorithmic problem!

The company has a machine that places electronic components on circuit boards. Normally, it would do this one component at a time. But recently the machine has received an update which allows it to place two different components simultaneously. The bottleneck then becomes the component with greater placement time. Now it is far from obvious what strategy the machine should use in order to minimize the total placement time. Sara decides to write an algorithm to determine this strategy.

You have $N$ different types of electronic components. There are $f_i$ copies of the $i$th type, and the components of this type have a placement time of $t_i$ nanoseconds. The goal is to place all of the components using a sequence of moves. In one move, the machine can take two components of type $i$ and $j,ドル where $i \neq j,ドル and place both of them simultaneously. This takes $\max(t_i, t_j)$ nanoseconds. The machine can also place a single component of type $i$ in one move, which takes $t_i$ nanoseconds.

Calculate the minimum possible time to place all components.

입력

The first line of input contains the integer $N$ (1ドル \leq N \leq 1000$).

The following $N$ lines each contain two integers $f_i$ and $t_i$ (1ドル \leq f_i \leq 10^4,ドル 1ドル \leq t_i \leq 10^9$).

출력

Print one integer, the minimum time to place all components.

제한

예제 입력 1

3
2 7
2 1
3 10

예제 출력 1

31

예제 입력 2

3
2 10
2 11
2 12

예제 출력 2

35

예제 입력 3

4
2 11
7 10
3 5
1 1

예제 출력 3

72

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > Nordic Collegiate Programming Contest > NCPC 2023 E번

  • 문제를 만든 사람: Bengt Evertsson, Nils Gustafsson
(追記) (追記ここまで)

출처

대학교 대회

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

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