After completing some serious investigation, Arif and Simon are now chilling themselves in the Ooty hills. Very soon Simon became bored. Simon lived entirely for his profession. We know he is a workaholic. So Simon wants to stop his vacation and get back to work. But after a tiresome season, Arif is in no mood to return soon. So to keep Simon engaged, he decided to give to pull the idea of restarting the admissions of the academy they started last year for the new academic year-2021.
Now Simon and Arif have decided to start the new admissions to the academy. As a part of the first round, the applied students had to solve a small puzzle. The puzzle was very simple. Arif has arranged N dummy statues in some order of height Hi.
Now Simon have made up the question asking to the applicants that In how many ways they can choose the sequence of consecutive dummy statues, where the tallest and shortest statue in the selected sequence is the same.
If you would like to get admission into his academy, your first step is to solve the question. Give it a try 🙂
Input:
First line of the input-number of test-cases.
For every test case, first line will contain n.Next line will contain n space separated integers denoting h.
Output:
Print the required answer
#include <stdio.h> #include<string.h> int main() { int t,n,h,i,l=1,count; scanf("%d",&t); while(t--){ l=1; count=0; scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%d",&h); if(h==l) { count+=2; } if(h>l) { l=h; count++;} } printf("%d\n",count); } return 0; }
INPUT_1:
2
3
2 3 4
3
4 4 5
OUTPUT:
3
4
INPUT_2:
2
3
2 4 3
3
4 4 5
OUTPUT:
2
4
Morae Q!
- Convert seconds to hours – HMS format.
- Find out the tax amount of the bill with tip for the meal.
- Find the area of the pyramid.
- Find the area of triangle using heron’s formula.
- Find the interest and amount resided in the bank.
- Convert the travel days to years and months.
- Find the first three powers of N number.
- Compute the height from feet and inches to centimetres.
- Calculate the amount of interest earned in the bank.
- Find the ways they can choose the sequence of dummy statues.
- Find the Lapindrome strings.
- Classify the salary of a person.
- Find the day on providing the week number.
- Find the least number of marble stones needed to pave the square mall.
- Find the number of steps on chessboard performed to satisfy a condition.
- Find the time, hours and minutes the train was delayed.
- Find the quantity of food packets shared and available.
- Compute all Arithmetic Operations.
- Find the amount to pay for the electricity bill.
- Find the sum of numbers with three values after decimal point.