Problem Description

You have tasks 1..n with durations. Also m dependencies (u v) meaning u must finish before v starts. Compute total minimum time to finish all tasks (no worker limit).

Input Format

Line1: n m. Line2: n durations. Next m lines: u v.

Output Format

One integer total time.

Sample Test Case

Input:
4 3 3 2 4 1 1 3 2 3 3 4
Output:
8

Constraints

1

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next