#1084
Unrated
POPUST
시간 제한
2s
메모리 제한
32MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Author: Goran Žužić

Mirko is hungry as a bear, scratch that, programmer and has stumbled upon a local restaurant. The restaurant offers N meals and has an interesting pricing policy: each meal i has two assigned prices, Ai and Bi. Mirko pays A only for the first ordered meal, while B prices apply for all other meals. Mikro can't decide how many meals to order. In order to make his decision easier, he has asked you to compute, for each k between 1 i N (inclusive), the minimum total price for k ordered meals. Mirko doesn't care which particular meals he orders or in which order he orders them, however he won't order the same meal twice. Order, order, order.

입력

The first line of input contains the positive integer N (2 ≤ N ≤ 500 000), the number of different meals offered by the restaurant. Each of the following N lines contains two positive integers, Ai and Bi (1 ≤ Ai, Bi ≤ 1 000 000 000), the prices for meal i as described above.

출력

Output must consist of N lines, where line k contains the minimum price for ordering exactly k different meals.

예제 입력 1

3
10 5
9 3
10 5

예제 출력 1

9
13
18

예제 입력 2

2
100 1
1 100

예제 출력 2

1
2

예제 입력 3

5
1000000000 1000000000
1000000000 1000000000
1000000000 1000000000
1000000000 1000000000
1000000000 1000000000

예제 출력 3

1000000000
2000000000
3000000000
4000000000
5000000000
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.