포럼
문제 ICPC00296

E. Electronic Components

설명

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
출력
31
예제 2
입력
3
2 10
2 11
2 12
출력
35
예제 3
입력
4
2 11
7 10
3 5
1 1
출력
72
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC NCPC 2023

평가 및 의견

E. Electronic Components

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

E. Electronic Components

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8