Question: Solve using C 2. Budget Babu Babu runs a small PG. It's his wife's birthday and hence he decides to give Chicken Biryani parcel to

Solve using C Solve using C 2. Budget Babu Babu runs a small PG. It's

2. Budget Babu Babu runs a small PG. It's his wife's birthday and hence he decides to give Chicken Biryani parcel to each student staying him PG. Babu has decided to give at least one parcel to each student in the pG. Based on no of years that a student spent in the PG, he decided to distribute the parcels. Each student must receive at least one parcel. Students who have stayed here for more number of will get more parcels than their neighbours. Help Babu find the minimum no of parcels required? Input First line contains integer T, denoting the number of test cases. For each test case: First tine contains integer N, denoting the number of students. Second tine contains N space separated integers, denoting the years of stay of each student. Output For each test case print the number of minimum no of parcels required on new line. The students must use array and functions appropriately Example 1 Input 2. 5 12152 2 12 Output 7 3) Explanation For testcase 1, adhering to rules mentioned above, Student \# 1 who stayed for 1 year gets one gift Student \# 2 who stayed for 2 years gets two gifts 5tudent of 3 who stayed for 1 year gets one gift. Student #4 who stayed for 5 years gets two gifts Student \# 1 who stayed for 2 years sets one gift Therefore, total parcels required is 1+2+1+2+1=7 Similarly, for testcase 2, adhering to rules mentloned above, 5tudent. A 1 who stayed for 1 year gets one gift Student 1 who stayed for 2 years gets two gifts Therefore, total gifts required is 1+2=3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!