Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Management Systems

Authors: Patricia Ward, George A Dafoulas

1st Edition

1844804526, 978-1844804528

More Books

Students also viewed these Databases questions

Question

Describe the role of HRD practitioners in OD interventions

Answered: 1 week ago