Wall Painting TCS NQT
Wall Painting TCS NQT
Problem:
Interior wall painting cost is X rupees per square feet and exterior wall painting cost is Y rupees per square feet. A house has M interior walls and N exterior walls to paint. The program must accept the surface area (in units of square feet) of the M interior walls and N exterior walls as the input. The program must print the total estimated cost with the precision up to 2 decimal places as the output.
Boundary Condition(s):
1 <= X, Y, M, N <= 100
Input Format:
The first line contains X and Y separated by a space. The second line contains M and N separated by a space. The next (M+N) lines, each contains a floating point value representing the surface area of a wall (Interior walls followed by exterior walls).
Output Format:
The first line contains the total estimated cost with the precision up to 2 decimal places.
Example Input/Output 1:
Input:
18 12
6 3
14.3 15.2 10.5 12.5 15.2 14.3 10.25 10.25 10.0
Output:
1842.00
Explanation:
The interior wall painting cost is 18 rupees per square feet and the exterior wall painting cost is 12 rupees per square feet. Here M=6 and N=3. The total surface area of 6 interior walls is 82 (14.3+15.2+10.5+12.5+15.2+14.3) square feet. The total cost to paint 6 interior walls is 1476 (82*18) rupees. The total surface area of 3 exterior walls is 30.5 (10.25+10.25+10.0) square feet. The total cost to paint 3 exterior walls is 366 (30.5*12) rupees. The total estimated cost with the precision upto two decimal places is 1842.00 (1476 + 366) rupees.
Example Input/Output 2:
Input:
7 10
4 3
24.5 12.2 13.7 5.6 32.5 10.2 12.3
Output:
942.00
Program:
x,y = map(int,input().split())
m,n = map(int,input().split())
tot_interior = 0
tot_exterior = 0
for i in range(m):
tot_interior += float(input())
for i in range(n):
tot_exterior += float(input())
cost_interior = tot_interior * x
cost_exterior = tot_exterior * y
print("%.2f"%(cost_exterior+cost_interior))
Comments
Post a Comment