GreedyGreedy

Job Sequencing with Deadlines

Schedule unit-length jobs with deadlines and profits to maximize total profit: take jobs in profit order and place each in the latest free slot before its deadline.

Learn Job Sequencing with Deadlines →
A
A
A
B
C
C
D
D
E
F
F
F
F
Time slots (one unit each)
1234
····
Jobs, most profitable first
iddeadlineprofitslot
A3100
B190
C260
D250
E140
F430
1/196 jobs, each taking exactly one unit of time and each worth its profit only if it finishes by its deadline. Row A's filled cells are the slots it is still allowed to run in — its feasible window [1, 3] — so this is the same interval picture as before, with "time unit" meaning "slot". We choose a subset and an assignment maximising total profit.
Slot being probedSlot this job was scheduled inFeasible window of a scheduled jobRejected job — no free slot before its deadline
1sort jobs by profit, highest first
2slot[1 .. maxDeadline] = free
3for each job (deadline, profit):
4 t = deadline
5 while t >= 1 and slot[t] is taken: t -= 1 # latest free slot
6 if t >= 1:
7 slot[t] = job; total += profit
8 else:
9 reject the job # every slot up to its deadline is full
10return slot, total
Variables
jobs6
slots4
profit0
Complexity
worst O(n log n + n · α(n))
space O(n + maxD)
Speed