Submit | All submissions | Best solutions | Back to list |
GSSQUNCE - Sequence |
Supervin likes counting. In this problem, he invites you to count together
Supervin defines an increasing sequence is a non-empty sequence {a1,a2,…ap} such that for all i < p, ai < ai+1
Supervin defines a decreasing sequence is a non-empty sequence {b1,b2,…bq} such that for all i < q, bi > bi+1
Supervin has a sequence {c1,c2,…cn} and he wants to divide the sequence into two sequences. Supervin requires that one of the sequences is an increasing sequence, while the other one is a decreasing sequence. Supervin may rearrange the numbers in his sequence before dividing it.
You are given the initial sequence that Supervin has. You have to determine whether Supervin can divide the sequence according to his condition.
Input
The first line consist of integer T, the number of cases (at most 20 each input file)
T cases follow. Each cases has :
Line 1 : Integer N, the number of integers in Supervin’s sequence.
Line 2 : N space-separated integers indicating Supervin’s sequnce.
Output
The output should contain T lines. The i-th line contains the output "YES" if Supervin can divide the i-th sequence as desired or "NO" if Supervin can't divide the i-th sequence as desired.
Example
Input:1
5
2 4 5 3 2
Output: YES
Explanation :
For example, he can divide the sequence to :
Increasing sequence : {2,3,4}
Decreasing sequence : {5,2}
Constraints
1 ≤ N ≤ 50 000
Each number in Supervin’s sequence is a non-negative integer less than 1 000 000 000
Added by: | jonathanirvings |
Date: | 2012-08-16 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Jonathan Irvin Gunawan |
hide comments
|
||||||
2013-06-01 16:58:12 Aradhya
for kids :) |
||||||
2012-12-29 16:30:29 intGeek
Test cases are weak.. My wrong code got AC.. :P |
||||||
2012-12-02 09:06:44 Aman Verma
my id is 8173636 . i am getting wrong ans in the 8th test case can anyone give me some tricky test case or can ne1 sort out my prob |
||||||
2012-10-10 20:35:06 Just Trying
Last edit: 2012-10-10 20:37:17 |
||||||
2012-08-25 22:36:37 (Tjandra Satria Gunawan)(曾毅昆)
Nice Problem ;) |