A1478.[COCI-2012_2013-contest2]#6 POPUST

省选/NOI-

COCI

通过率:0%

时间限制:1.00s

内存限制:128MB

题目描述

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

说明/提示

Clarification of the first example:
k = 1: Mirko pays A2 = 9 for the starting meal 2.
k = 2: Mirko pays A1 = 10 for the starting meal 1, then B2 = 3 for meal 2.
k = 3: Mirko pays A1 = 10 for the starting meal 1, then B2 = 3 for meal 2, and finally B3= 5 for meal 3.

首页