0

Problem: Given N tasks with potentially non-unique deadlines d1,...,dN and time needed t1,...,tN to complete each one (in hours), output a schedule that maximizes the number of deadlines met. Only 1 task can be worked on at any time.

Is there an efficient algorithm for this problem? I seems like a slight modification to the task scheduling problem (n tasks, n deadlines, each task takes 1 unit of time, 1 task at a time), which has an efficient greedy algorithm (do unexpired task with nearest deadline).

I am thinking the following DP algorithm might be optimal:

Subproblem: f(i, t) is maximum # deadlines meetable given tasks i...|T| to choose from, and start time is t

Recurrence: f(i, t) = max(f(i+1, t+ti), f(i+1, t))

Runtime: O(|T|*max(di))

Is this algorithm even efficient (would the runtime be considered polynomial)? If not, is there another efficient algorithm?

  • 1
    Welcome to SO. Please take a [tour] and read [ask] for tips how to write a good question. You can [edit] your question with a [example] showing what you have already tried and what part is not working. – koen Nov 11 '22 at 02:52
  • https://www.geeksforgeeks.org/job-sequencing-problem/ – Rinkesh P Nov 11 '22 at 04:53
  • That is a different problem. Here I am asking about jobs that take a variable amount of time, and there the "profit value" is the same for all jobs. – mega-rototo Nov 11 '22 at 05:07
  • I don't think the proposed algorithm is optimal. Consider a task T1 with `d=4 t=4` and five other tasks (T2 to T6) with `d=5 t=1`. If you choose T1, then you'll only get two tasks done. If you reject T1, you'll get all five of the other tasks done. – user3386109 Nov 11 '22 at 06:19
  • That's a great point, thanks for your input. Looks like this problem is harder than I thought... – mega-rototo Nov 11 '22 at 06:31
  • I think I'd start at the end. Every task can be started at time 0 (assuming of course that `d[i] >= t[i]`). But only some tasks can be finished at the last deadline. So starting at the last deadline reduces the number of choices. – user3386109 Nov 11 '22 at 07:02

0 Answers0