Close
Topic list
City Lights
HARD
50 mins
Sorting
Topics (Covered in this problem)
Problem solved
Skill meter
Sorting
-
-
Other topics
Problem solved
Skill meter
Strings
-
-
Matrices (2D Arrays)
-
-
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
Arrays
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

# City Lights

Contributed by
Jaypal Mudaliyar
Hard
0/120
Avg time to solve 50 mins
Success Rate 40 %
Share

## Problem Statement

.

#### NOTE: The replaced street lights should cover each and every part of the city.

##### EXAMPLE :
``````Input: ‘L’ = 8, ‘B’ = 10, ‘N’ = 1, ‘POS’ = {4}, ‘R’ = {5}

Output: -1
In this case,
``````

``````As shown in the figure above, even if we fix the only street light of the city, the whole city area can’t be covered. Hence the output is ‘-1’.
``````
Detailed explanation ( Input/output format, Notes, Constraints, Images )
##### Sample Input 1 :
``````2
6 6 3
6 1 4
1 0 5
10 4 2
2 7
1 1
``````
##### Sample Output 1 :
``````1
-1
``````
##### Explanation Of Sample Input 1 :
``````For the first test case,
``````

``````It is clearly visible, that it is advantageous to fix only the street light at position ‘4’.
Hence, the output will be: 1

For the second test case,
``````

``````It is clearly visible, that even if we fix all the street lights of the city, we can’t have the luminance of new street lights in the whole city. Hence the output is ‘-1’
Hence, the output will be: -1
``````
##### Sample Input 2 :
``````2
20 6 4
1 8 13 20
5 5 5 5
5 1 5
0 1 2 3 5
0 0 0 0 1
``````
##### Sample Output 2 :
``````4
-1
``````
Auto
Console