Eat Economically

2N개의 메뉴 중에서 2i개를 골라 점심값과 저녁값의 합이 최소가 되도록 하고, i가 1부터 N일 때의 최솟값을 각각 출력한다.

어려움8그리디정렬구현아직 제출이 없습니다시간 제한3초메모리 제한1024 MB

문제

Ho has arrived in a secret place for her secret business trip. She knows her trip will take at most NN days or shorter but doesn't know the exact number of days she'll be there. So, the perfectionist Ho wants to make the daily meal lists for every possible trip length, 11 day to NN days.

There is the only food court that offers exactly 2N2N kinds of menus (by accident) in this secret place. The food court opens only lunch time and dinner time, and oddly, the prices of lunch and dinner for the same menu can be different.

She will eat exactly one menu per lunch and dinner respectively and never eat the same menu for the entire of the trip. She never minds about which kind of menu will be her meal, the only important thing is the entire price of meals must be minimized.

Under these conditions, she can make her meal lists but realizes that writing every N(N+1)N(N+1) menu is hard and tiresome. So, instead of making the meal lists, she calculates the minimized entire price for ii lunch menus and ii dinner menus where i=1i=1 to NN.

You, the big fan of Ho, has a supreme task. Print the NN prices she calculated.

입력

The first line contains an integer NN.

In the next 2N2N lines, each line contains two integer l,dl, d denoting the prices of the menus when lunch and dinner respectively.

출력

Print NN lines. The ii-th line (1iN1 \le i \le N) should contain an integer denoting the minimized entire price for ii lunch menus and ii dinner menus.

제한

  • 1N250,0001 \leq N \leq 250\\,000
  • 1l,d1091 \leq l, d \leq 10^9