ADWFNSNW - A Dwarf - N Snow Whites

Today RomanD3 wants to race his old bicycle to Do Son beach with two friends of his, on his way he thought out a problem named "A Dwarf - N Snow Whites":

On his hard way to Do Son beach, he races with N Snow White racing on N different bicycles, but none of them wants to go alone. Given that the ith Snow White wants to be taken by the dwarf RomanD3 for Ti minute(s), then she can go alone for (only) Di minute(s) (she will cry after that); RomanD3 wants to "escape" from them soon to go... by bus with the N+1th Snow White on the bus (whom he likes), so he must take each Snow White exactly one time but not let any of them cry; then he needs at least one minute to go with his lady (in dream ;)) ).

Please help him to determine whether he can do or not.

Input

- The first line contains number N.
- Next N line(s), the ith line contains two numbers Ti, Di.

Output

- Print out -1 whether he can not "escape" from them or print out the order of serving them before he can jump on the bus ;))

Example

Input:
2
2 11
11 30

Output:
2 1

Limitations

- n ≤ 105.


Được gửi lên bởi:AnhDQ
Ngày:2009-05-25
Thời gian chạy:0.100s-1.200s
Giới hạn mã nguồn:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Ngôn ngữ cho phép:Tất cả ngoại trừ: ERL GOSU JS-RHINO NODEJS PERL6 PYPY RUST SED VB.NET
Nguồn bài:AnhDQ - RomanD3 :))

hide comments
2013-06-04 03:09:18 Nguyễn An
vãi đề =)))
2010-11-27 04:39:06 Nguyễn Quang Anh
bài này nhờ P/s xem lại tính đúng đắn của bộ Test hộ mình với nhé :D.

add: ca gioi han Ti, Di nua.

Last edit: 2010-11-27 04:41:02
2009-06-02 03:34:10 Zeratul
"dù chỉ 1 phút thôi cũng được" nghĩa là phải dư ra ít nhất 1 phút mà N nàng vẫn chưa khóc à?

Re: Đúng rồi :)

Last edit: 2009-06-02 04:20:32
2009-05-26 01:20:33 Nguyễn Xuân Khánh
output để khoảng trắng ở cuối có ảnh hưởng không nhỉ ?

Re:
không ảnh hưởng, bạn bị WA :-)

Last edit: 2009-05-26 01:46:00
2009-05-25 18:32:36 ngockingspeed
o test vd thi kq = 1 2 co sao dau nhi

Re:
1. nếu có nhiều kq, chỉ cần in ra 1
2. bạn đọc kĩ lại đề :)

Last edit: 2009-05-25 23:42:13
2009-05-25 17:41:38 AnhDQ
chiều lòng cháu Đạt một tí :))
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.