Athenaeus has recently wrapped up making his most recent melodic piece and will introduce it tomorrow to individuals of Athens. Tragically, the tune is somewhat dull and almost certain will not be met with a warm gathering.    His tune comprises of n notes, which we will treat as certain integers. The variety of a tune

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter10: Classes And Data Abstraction
Section: Chapter Questions
Problem 19PE
icon
Related questions
Question

Correct answer will be upvoted else Multiple Downvoted. Computer science.

Athenaeus has recently wrapped up making his most recent melodic piece and will introduce it tomorrow to individuals of Athens. Tragically, the tune is somewhat dull and almost certain will not be met with a warm gathering. 

 

His tune comprises of n notes, which we will treat as certain integers. The variety of a tune is the number of various notes it contains. As a supporter of music, Euterpe looks after arrangers and guides them all through the method involved with making new tunes. She chose to help Athenaeus by changing his melody to make it more assorted. 

 

Being a minor goddess, she can't self-assertively change the tune. All things being equal, for every one of the n notes in the tune, she can either leave it for what it's worth or increment it by 1. 

 

Given the tune as an arrangement of integers portraying the notes, discover the maximal, attainable variety. 

 

Input 

 

The input comprises of numerous experiments. The principal line contains an integer t (1≤t≤10000) — the number of experiments. Then, at that point, t experiments follow, every one is portrayed in two lines. 

 

In the principal line of each experiment there is a solitary integer n (1≤n≤105) meaning the length of the melody. The following line contains an arrangement of n integers x1,x2,… ,xn (1≤x1≤x2≤… ≤xn≤2⋅n), portraying the melody. 

 

The amount of n over all experiments doesn't surpass 105. 

 

Output 

 

For each experiment, you should output a solitary line containing exactly one integer, the maximal variety of the melody, for example the maximal conceivable number of various components in the last succession.

 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Introduction to computer system
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole