The Riverbend Municipal Grid runs a rebate program for community electric-vehicle charging stations. A station operator earns the rebate if at least one of their charging sessions is a peak-window session: its calendar date falls within an announced date window, the time of day it started falls within an announced daily time window, and the energy it delivered meets a minimum threshold.
You are given a log of charging sessions, each recording the operator's id, the session's start date, the session's start time of day, and the energy delivered (in kWh). Given the program's date window, daily time window, and minimum energy, report every operator id that has at least one qualifying session.
Line 1: an integer n, the number of session records.
Next n lines: each contains operator_id date time energy, where date is YYYY-MM-DD, time is HH:MM in 24-hour zero-padded form, and energy is a non-negative integer.
Next line: startDate endDate, both in YYYY-MM-DD form, with startDate <= endDate.
Next line: startTime endTime, both in HH:MM form, with startTime <= endTime.
Next line: an integer minEnergy.
Print the distinct qualifying operator ids in ascending numeric order, space-separated on a single line. Print an empty line if no operator qualifies.
n <= 1000operator_id <= 100002000-01-01 and 2100-12-31.energy, minEnergy <= 1000startDate <= date <= endDate AND startTime <= time <= endTime AND energy >= minEnergy (comparisons on date and time are exact string comparisons on the zero-padded formats above, which agree with chronological order).Example 1
Input
3 5 2024-01-10 09:30 50 7 2024-01-15 11:00 20 5 2024-02-01 09:45 80 2024-01-01 2024-01-31 09:00 10:00 40
Expected
5
Explanation
Operator 5's first session (2024-01-10, 09:30, 50 kWh) falls within the date window [2024-01-01, 2024-01-31], within the time window [09:00, 10:00], and delivers at least 40 kWh, so it qualifies. Operator 7's session is within the date window but its time (11:00) is outside [09:00, 10:00], so it fails to qualify. Operator 5's second session falls outside the date window (2024-02-01 is after 2024-01-31), but operator 5 already qualified via the first session. The only qualifying operator is 5.
Example 2
Input
2 3 2024-05-05 08:00 100 3 2024-05-06 08:30 90 2024-05-01 2024-05-31 08:00 09:00 90
Expected
3
Explanation
Both of operator 3's sessions fall within the date window [2024-05-01, 2024-05-31] and the time window [08:00, 09:00], and both deliver at least 90 kWh, so operator 3 qualifies. Since only one distinct operator appears, the output is just 3.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →