CodeVita 2017 Round 2 C

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

11/08/2017 TCS: CodeVita - Coding Arena

TCS NextStep TCS Careers www.tcs.com Logout

Welcome Home Coding Arena Compile & Run Submissions Graphs Feedback

Time Left

Coding Arena 06 00 00
Change Default Language hr min sec

A B C D E F G H

Rules & Regulations


Problem : Air in the balloons
Launch Code Editor
You have been given 'N' number of spherical Balloons of different radius when filled. You have to fill one balloon per day and
the last balloon will be filled on Nth day. There is some rate of air reduction 'K' per day from each balloon. Fill the balloons in Notifications
such an order so that the sum of the volume of all the balloons is maximum on the day when all the balloons are filled.

Input Format: Status messages

First Line is an integer N giving the number of balloons.

Second line gives space separated N positive real numbers with up to 1 decimal place giving the radii of the balloons.

Third line gives K, the rate of reduction in the volume of air as a percentage.

Output Format:

Maximum sum of volumes of all the balloons on the Nth day when all the balloons are filled. Take 3.14 as the value of PI and
give the answer to two decimal places (truncated by ignoring all the decimals from third onwards). Note that the truncation
should happen only after computing the volume of all the balloons on the final day to maximum precision.

Constraints:

Number of balloons <= 10


Radius of balloons <=200

Example 1

Input
5
8 4 6 10 3
10

Output
7117.88

Explanation
If we fill the balloons in the order 3, 4, 6, 8, 10, their volumes on the fifth day are respectively
74.165544
195.33312
732.4992
1929.216
4186.666667
And their sum is 7117.880531. Truncating the value two decimal places, we obtain 7117.88

Example 2

Input
7
3.5 9 4 6.6 7 11 9.1
12.5

Output
12555.35

Explanation
If we inflate the balloons in the order 3.5 4 6.6 7 9 9.1 11, their volumes on the seventh day would be respectively
80.56025567
137.4322396
705.5574848
962.0256771
2336.74875
2760.581763
5572.453333 The sum of these volumes is 12555.3595 and truncating to two decimal places, we obtain 12555.35

https://www.tcscodevita.com/CodevitaV6/problemstart.jsp 1/2
11/08/2017 TCS: CodeVita - Coding Arena

Note:

Please do not use package and namespace in your code. For object oriented languages your code should be written in one
class.
Note:

Participants submitting solutions in C language should not use functions from <conio.h> / <process.h> as these files do not
exist in gcc
Note:

For C and C++, return type of main() function should be int.

© 2017 Tata Consultancy Services Limited. All Rights Reserved.

Submit Answer

I ,confirm that the answer submitted is my own.I would like to


provide attribution to the following sources.

Select Language
Select File
Browse...

© 2017 Tata Consultancy Services Limited. All Rights Reserved. In Association with | Privacy Policy

https://www.tcscodevita.com/CodevitaV6/problemstart.jsp 2/2

You might also like