The Ruthless Boss
InterviewTime limit2sMemory limit512 MB
Given n distinct deadlines, find the largest integer k so that scheduling all jobs, each taking exactly k hours back to back, meets every deadline.
- Level
Medium5 of 10
- Topics
- Greedy, Sorting, Binary search, Math
- Solved
- No attempts yet
Problem
zych runs Namgyu Company and is known for working the staff to the bone. Today zych is again planning how to squeeze more hours out of them.
The company has jobs, and every job has its own deadline. Missing a deadline costs a contract penalty, so all jobs have to be finished. Spending too little time on a job lowers the quality of the result, so zych wants the staff to spend as much time as possible on each one. Different durations confuse the staff, so every job takes exactly hours.
Work starts at time and the jobs run one at a time, back to back with no idle gap. A job with deadline must finish at a time no later than . You choose the order of the jobs.
Given the deadlines, print the largest integer for which every job finishes by its deadline.
Input
The first line contains the number of jobs . ()
The second line contains the deadlines , separated by spaces. () No two jobs share a deadline.
Output
Print the largest integer for which every job finishes by its deadline.