BAT2 - BATMAN2

Alfred: "I'll get this to Mr. Fox, but no more. I've sewn you up, I've set your bones, but I won't bury you. I've buried enough members of the Wayne family."

After being promised the software to erase her criminal record, Catwoman agrees to take Batman to Bane. They manage to defeat all of Bane's men but ended up heading into a MAZE trap. Bane would call this maze as the LIS MAZE. He would hide himself in one of the rooms. Each of these rooms have a number (tag) associated with it. The speciality of the maze is that once you enter any room it will only lead you to rooms with a higher tag in the direction you move. Batman and Catwoman decide to move in opposite directions trying their luck to maximize the number of rooms they search. (They can start with any room, need not be the same)

Catwoman: "Never steal from someone you can't outrun, kid."

Input

t, number of test cases.
n, number of rooms.
n integers giving the tag associated with the rooms.

Output

The maximum number of rooms searched.

Constraints

1 ≤ n ≤ 100

Example

Input:
1
6
5 3 4 6 1 2

Output:
5

Added by:Romal Thoppilan
Date:2013-02-06
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:own problem

hide comments
2015-07-28 09:47:06 Bhuvnesh Jain
@Romal, can you check why is 1st solution is getting WA. I think my algo is correct. It gives 5 as output on test case as well
2015-07-28 09:47:04 Bhuvnesh Jain
@Romal, can you check why is 1st solution is getting WA. I think my algo is correct. It gives 5 as output on test case as well
2015-03-27 04:30:49 Micky
Can different rooms have same number(tag)???
2014-08-04 04:30:11 Rishav Goyal
A[i]<=100.

Last edit: 2014-08-04 04:30:23
2014-06-25 13:32:51 [themighty] deathsurgeon
What is the range of these n integers (i.e., tags)?

Last edit: 2014-07-21 15:59:59
2013-08-27 05:19:44 Hamdi Ahmadi Muzakkiy
anyone have testcase?
2013-07-30 11:47:09 Taym
The number of each room is positive, or could it be negative ?

Last edit: 2013-07-30 17:41:23
2013-07-28 05:03:35 Ahmed Malatawy
@Romal
How is the test case correct?
If Batman can only move to the right then the maximum would be 3 (3->4->6). Right?
2013-06-18 10:01:26 Murukesh Mohanan
Some conditions that aren't immediately obvious to me:
1. Access to any room with a higher tag is allowed, not just adjacent rooms or the next room with a higher tag.
2. Tags are unique.
So given the input:
12 11 10 1 2 3 4 13 6 7 8 5 9
the answer is 12: (1,2,3,4,6,7,8,9) and (5,10,11,12).
2013-06-14 18:51:30 Murukesh Mohanan
The Test case should be 4, either (3->4->6, 3->5) or (3->4->6,1).
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.