Archive / 2022 / February 2022
No Electricity Hour
There’s a distant island named Ãkkåy Island, that uses a different timing convention. Unlike ours, this island has D days per month and H hours per day. The island is divided into S number of sections. This island is having a hard time finding fuel for electricty generation. So, to overcome this, they have decided to stop providing power for various sections of the island to control the fuel usage for power generation. So, the smart people in this island have come up with a plan, to stop power for different sections in different intervals. So, every section would loose power for one hour, after different number of hours(Ys). Due to this, there are some hours, where the whole island looses power. And the people on this island have begun to call this hour as “No Electricity Hour”.
Given a time of a no electricy hour(T1), you are supposed to find whether a given time(T2) is a no electricity hour. If it’s not a no electricity hour, find X, the number of hours to the closest no electricity hour.
Input Format
First line contains 3 integers, D, H & S describing the number of days per month, number of hours per day and number of sections in the island respectively.
Next line contains S integers, Y1, Y2, …, Xn, describing the number of hours between a power cut for each section.
Next line contains 3 integers, m1, d1, h1. The month, date and hour of T1 respectively.
Last line contains 3 integers, m2, d2, h2. The month, date and hour of T2 respectively.
Output Format
If T2 is a Full Moon Day, print “NO ELECTRICITY HOUR”.
If not, print a single positive integer X, the number of hours to the closest no electricity hour.
Constraints
If the number of hours between T1 & T2 is D,
- 1 \(\leq\) D, H \(\leq\) 104
- 1 \(\leq\) S \(\leq\) 102
- 1 \(\leq\) Ys \(\leq\) D * 3
- 1 \(\leq\) D \(\leq\) 108
- 1 \(\leq\) m1, m2 \(\leq\) 108
- 1 \(\leq\) d1, d2 \(\leq\) D
- 1 \(\leq\) h1, h2 \(\leq\) H
Limits
- Time Limit: 1s
- Memory Limit: 256MB
Sample Input 0
30 24 1
26
2 24 8
2 25 10
Sample Output 0
NO ELECTRICITY HOUR
Sample Input 1
20 12 2
3 2
2 1 1
2 1 12
Sample Output 1
1
Open on HackerRank ↗ · Markdown source · Back to the archive