Skip to content

Latest commit

 

History

History
28 lines (15 loc) · 852 Bytes

abc103_a_task_scheduling_problem.md

File metadata and controls

28 lines (15 loc) · 852 Bytes

Task Scheduling Problem

Original problem · C++ solution

Try first

Every route must cover the distance between the extremes.

Reasoning

Every route must cover the distance between the extremes. Visiting tasks in sorted order attains that distance.

Cost

  • Time: O(1).
  • Extra space: O(1).

C++ takeaway

Integer division truncates toward zero; use remainder to test divisibility. Evaluate products in long long before assigning the result.

Watch for

Follow the exact input and output formats; check the smallest allowed input.

Explain it back

State the invariant without looking at the code. Give one input that breaks the most tempting incorrect approach, then add it to the tests.