Grand sale
Practice
3 (1 votes)
Algorithms
Approved
Dynamic programming
Hard
Recruit
Problem
61% Success 350 Attempts 50 Points 2s Time Limit 256MB Memory 1024 KB Max Code

An e-commerce company is afraid of overloads on its website. So they have planned to use dedicated servers for each item going on sale. To minimize the cost, they are required to manage the traffic with a minimal number of servers. Additionally, each server needs \(5\) minutes time to be switched for its use from the current item to another. For the first item the server handles, it does not take any time as it had been configured a day before. Write a program to manage the servers.

Input format

  • First line: \(n\) denoting the number of items on sale
  • Next \(n\) lines: Format \(hh\ mm\ HH\ MM\) where \(hh\ mm\) is the starting time and \(HH\ MM\) is the ending time of an item's sale (both inclusive)

Output format

Print the minimum number of servers required to accomplish an issue of free sale.

Note

  • \(hh\ mm\) is represented in 24-hour format.
  • If a sale finishes at \(10\ 20\) and another sale starts at \(10\ 25\), then the same server can be used as they have a 5-minute time gap.

Constraints

\(1 \le n \le 1000\)

\(00 \le hh,HH \le 23\)

\(00 \le mm,MM \le 59\)

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:50
3 votes
Tags:
AlgorithmsApprovedDynamic ProgrammingHardReadyRecruitTwo pointer
Points:50
10 votes
Tags:
Introduction to Dynamic Programming 1AlgorithmsDynamic ProgrammingBit manipulation
Points:50
1 votes
Tags:
Dynamic ProgrammingIntroduction to Dynamic Programming 1Algorithms