Computer Science, asked by suhraj7631, 5 hours ago


Nikhil's birthday is coming on 8th March.
His friend Vivek is planning to throw a surprise party without his knowledge, so he make a plan to call all
Nikhil's friend to Toit restaurant.
He came up with an idea of sitting plan at restaurant in such a way that the person with lowest friendship
sits in starting and a person with highest in the end.
Two or more persons can have same level of friendship.
Nikhil's friends are sitting randomly and vivek can bribe every friend with a candy and only swap two
adjacent friends.
Vivek is busy in other arrangement too so, he check the first and last person's friendship level to confirm
the seating arrangement
So Vivek wants to calculate the minimum candies need to make all look good.
Input:
T denoting number of test cases,
Then T test cases follow each containing a number N denoting number of friends.
Next line contains N friends having their friendship level.
Output:
Output the minimum candies it would take to complete the task.
Constraints
1 <= T <= 500
1 <= N <= 100000
1 <= M <= 100000​

Answers

Answered by LightningAgent
0

Answer:

sorry dude I don't know the answer of this question, is this MAT?

Similar questions