The TransCompilator

Solved LeetCode program · 966 of 1,000

#1335 · Minimum Difficulty of a Job Schedule

Hard Array chunk-20.md

Original English source

Keep a shared jobs holding 6, 5, 4, 3, 2, and 1. Keep a shared days of 0. Keep a shared size of 0. Set days to 2. Set size to 6. Keep a shared possible of 0. Keep a shared peak of 0. Keep a shared answer of 0. Set possible to 1. If days is more than size, set possible to 0.

To weigh from start (a whole number) with finish (a whole number). Set peak to 0.
For every job from start to finish.
If item job of jobs is more than peak, set peak to item job of jobs.

To plan. The width is size plus 1. The cells is (days plus 1) times width. The table is a list of cells zeros.
For every spot from 0 to the last position of table.
Set item spot of table to 1000000. Set item 0 of table to 0.
For every day from 1 to days.
For every finish from 1 to size.
For every split from day minus 1 to finish minus 1.
Weigh from split with finish minus 1. The prior is item ((day minus 1) times width plus split) of table. The candidate is prior plus peak. If candidate is less than item (day times width plus finish) of table, set item (day times width plus finish) of table to candidate. Set answer to item (days times width plus size) of table.

If possible is 0, show -1. If possible is 1, plan. If possible is 1, show answer.

Open in Playground Browse all 1,000 problems

Expected stdout

7