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?

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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).

Expert Solution
steps

Step by step

Solved in 5 steps with 2 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education