Submit | All submissions | Best solutions | Back to list |
PRQUEUE - PRAYER QUEUE |
In Jhonny' class, there are unlimited students of different heights, including Jhonny.But on a specific day there are only n students are present. Everyday Jhonny remains anxious to find who will stand behind him in the prayer queue, a boy or a girl. He wants his best friend, Kelly, to find the same for him.
Given the height of n students and Jhonny, too, find the height of student who will stand behind him in the queue.
Constraints:
- 1 <= number of students, n <= 1000
- 1 <= height of i'th student, hi <= 10000 for i = {1, 2, ..., n}
- Each height will be different.
- Students stand in the queue in the increasing order of their height.
- Jhonny is not the longest boy present that day.
Input
The first line of the input contains t, number of test case. Then follows t test cases.
Each test case contains two lines. The first line has two numbers, n h, the number of students and height of Jhonny.
In the next line there are n numbers, h1 h2 h3 ... hn, representing the height of all the n students, including Jhonny's height.
There are about 150 test cases.
Output
Find the height of the person who will stand behind Jhonny in the queue.
Example
Input:
3
5 6
4 2 6 8 7
3 2
1 2 3
6 55
3 44 55 11 75 12
Output:
7
3
75
Explanation for test case #1:
5 6
4 2 6 8 7
Jhonny's height = 6
The boy with height 7 will stand behind him in the queue.
Added by: | abhiranjan |
Date: | 2011-02-19 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | C CSHARP C++ 4.3.2 CPP JAVA |
Resource: | IIITM Local Contest |
hide comments
2018-06-15 09:59:22
I don't understand, why the result of case 1 is not 8 but 7, and of case 3 is not 11 but 75? |