OmkArray of a cluster a with components a1,a2,… ,a2k−1, is the exhibit b with components b1,b2,… ,bk to such an extent that bi is equivalent to the middle of a1,a2,… ,a2i−1 for all I. Omkar has discovered a cluster b of size n (1≤n≤2⋅105, −109≤bi≤109). Given this cluster b, Ray needs to test Omkar's case and check whether b really is an OmkArray of some exhibit a. Would you be able to help Ray?
Please answer in c++. Correct answer will upvoted else downvoted.
The OmkArray of a cluster a with components a1,a2,… ,a2k−1, is the exhibit b with components b1,b2,… ,bk to such an extent that bi is equivalent to the middle of a1,a2,… ,a2i−1 for all I. Omkar has discovered a cluster b of size n (1≤n≤2⋅105, −109≤bi≤109). Given this cluster b, Ray needs to test Omkar's case and check whether b really is an OmkArray of some exhibit a. Would you be able to help Ray?
The middle of a bunch of numbers a1,a2,… ,a2i−1 is the number ci where c1,c2,… ,c2i−1 addresses a1,a2,… ,a2i−1 arranged in nondecreasing request.
Input
Each test contains various experiments. The main line contains a solitary integer t (1≤t≤104) — the number of experiments. Depiction of the experiments follows.
The primary line of each experiment contains an integer n (1≤n≤2⋅105) — the length of the cluster b.
The subsequent line contains n integers b1,b2,… ,bn (−109≤bi≤109) — the components of b.
It is ensured the amount of n across all experiments doesn't surpass 2⋅105.
Output
For each experiment, output one line containing YES if there exists a cluster a to such an extent that bi is the middle of a1,a2,… ,a2i−1 for all I, and NO in any case. The instance of letters in YES and NO don't make any difference (so yEs and No will likewise be acknowledged).
Step by step
Solved in 5 steps with 2 images