Difficulity
：
N/A

Accepted : 123 Times | Submit :490 Times | Clicks : 2069

Accepted ： 55 Users | Submit : 63 Users | Accepted rate : 87%

Time Limit ：3000 ms | Memory Limit : 64000 KBytes

題目加入時間 : 2011-02-23 14:35

Accepted : 123 Times | Submit :490 Times | Clicks : 2069

Accepted ： 55 Users | Submit : 63 Users | Accepted rate : 87%

Time Limit ：3000 ms | Memory Limit : 64000 KBytes

題目加入時間 : 2011-02-23 14:35

**
Content
：**

Taipei lOl (LOL != 101) is a power-saving building.

Therefore, passengers enter their desire floors at 1F. Then the elevator goes up and stop at a floor N.

All the passengers leave the elevator at floor N and start to climb up or down to their desired floors.

Let S is the total floors of those passengers have to climb (up/down).

Please write a program to calculate N that produces the smallest S.

The elevator only stop once and all the passengers must leave the elevator to walk.

If there is more than one N produce smallest S, please select the smallest N because we need to save power.

**
Input
：**

There are many sets of data.

Each line is two integers F and K. It means there are K people wish to go to floor F.

If F and K are both 0, which means end of this set of data.

**
Output
：**

For each set of data, output a line of two integers N and S.

N is the floor where the elevator stops.

S is the total floors that the passengers have to climb.

**
Sample Input
：**

101 100 0 0 1 100 0 0 2 1 3 1 4 1 5 1 6 1 0 0

**
Sample Output
：**

101 0 1 0 4 6

**
Hint
：**

**
Author
：**

C++ |
C |
JAVA |
---|---|---|

29756. admin
(88 ms
, 370KB) 29459. henryokc (98 ms , 372KB) 29633. cp99703009 (100 ms , 226KB) 29722. cp99703043 (108 ms , 240KB) 46405. ji8g2mu (132 ms , 244KB) |
29603. cp99703032
(28 ms
, 232KB) 29527. cp99703032 (28 ms , 224KB) 29973. cp99703040 (30 ms , 242KB) 29616. cp99703008 (30 ms , 234KB) 29757. admin (34 ms , 230KB) |
63419. nwgs524513cja
(
1.2
s
, 18046KB) |

執行時間會受很多因素影響因此僅供參考，主機等級請看這裡