Place the AC
Practice
0 (0 votes)
Easy Medium
Problem
76% Success 316 Attempts 30 Points 2s Time Limit 256MB Memory 1024 KB Max Code

Air conditioning usage: Rooms in a hospital corridor are stacked next to each other in such a way that the wall separating 2 rooms only occupy half the height of the room, There is provision for installation of AC’s in some of the rooms and the hospital is looking to procure ACs. ACs are categorised as {1 tonne, 2 tonne, 3 tonne "x" tonne} based on the area they are capable of cooling; larger the tonnage more area they are capable of cooling. Assume that 1 tonne AC cools 1 room, 2 tonne AC cook) the room and its adjacent rooms arid so on and so forth . Suppose there are "n" rooms next to each other numbered 1 to n, And that the value for "n" as well as the room numbers having provision for installation of ACs are giver as Input. Write a program that figures out the minimum tonnage of AC's to be procured to cool all the rooms. Assume that the tonnage for all the ACs being procured is the same g)

Input:

First line consists of a single integer, R - number of rooms.

Second line consists of a single integer, P, denoting the number of positions to place AC’s .

Third line consists of a N integers separated by a space. A[N]. (Position to place AC)

Output:

For each test case, print the minimum number of AC’s required.

Constraints:

1<=R<=10000

1<=P<=10000

1<=N<=10000

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
2 votes
Tags:
Easy-MediumMath
Points:30
3 votes
Tags:
Ad-HocEasy-MediumMath
Points:30
77 votes
Tags:
MathematicsOpenApprovedEasy-MediumMathamatics
Editorial

No editorial available for this problem.