Submit | All submissions | Best solutions | Back to list |
BWIDOW - Black Widow Rings |
Black Widow has a collection of N (numbered 1 to N) Rings. She uses the rings to attack the enemies. She has decided to use one ring for distraction. She will first throw the distraction ring and then all the other rings will be thrown through it (one at a time). Each ring has an inner and outer radius.
A ring R1 will pass through ring R2 only if the outer radius of R1 is less than the inner radius of R2.
If she can chose a distraction ring from the given collection print the index of the ring (1-based), else print -1.
Input
The first line of the input contains an integer T denoting the number of test cases.
The first line of each test case contains a single integer N denoting the number of Rings.
Next N lines consists of Inner and Outer Radius of the ith Ring - r, R.
- 1 ≤ T ≤ 100
- 2 ≤ N ≤ 1000
- 1 ≤ r < R ≤ 107
(Edited: r and R are integer)
Output
For each test case print the desired result in separate line.
Example
Input: 2 3 2 3 6 8 3 5 3 4 5 5 8 3 10 Output: 2 -1
Added by: | BLANKRK |
Date: | 2013-11-14 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Code Weavers 2013 |
hide comments
|
||||||||
2017-01-22 18:27:48
simple one did in O(n) |
||||||||
2017-01-14 10:20:01
AC in one go feels good, although easy :p |
||||||||
2016-10-28 11:00:21
ac!! o(n) |
||||||||
2016-07-14 15:42:55
Gave Compliation error...and AC d same code in next attempt?? What is the reason behind that>> |
||||||||
2016-07-12 10:46:11 geeta
damn stupid que!!! unexpected AC -_- |
||||||||
2016-07-04 09:43:02
@noob909 dont worry ..there are no such inputs where inner radius is greater than outer. my accepted solution gives -1 for your test case |
||||||||
2016-06-13 19:59:17 noob909
1 3 2 10 6 5 3 4 AC output for this 2 but didnt understand .i think -1 will be output |
||||||||
2016-04-24 14:27:37
U can use pairs from stl and AC |
||||||||
2015-08-10 17:40:49 shravinson
https://ideone.com/0E9Y1d got ac not working for 1 3 2 100 14 56 45 67 |
||||||||
2015-08-03 16:45:40 Mayank Garg
100th green light :D ... O(n) ;) |