SalesforceOA #18
Get Minimum Development Time
Estimated MediumJudge-ready
Topics (AI-labelled)GreedyPrefix & Ranges
Each feature is handled in exactly one of two ways: development takes developmentTime[i], and integration takes integrationTime[i]. Development is carried out simultaneously by as many members as needed, while integration is done sequentially by the team lead alone; the two kinds of work may overlap. Find the shortest time to finish everything. The parallel/serial conditions were recovered from the original HTML.
Input
The first line contains n, followed by two lines giving the development times and the integration times respectively. On this site 1≤n≤200000, and both kinds of times are in 1..10⁹.
Output
Output the shortest schedule length. The intermediate sum of integration times requires 64 bits.
Example 1
Input:
5
10 12 13 8 15
1 2 1 1 1
Output:
6
Example 2
Input:
2
2 100
100 3
Output:
3
Example 3
Input:
1
1
100
Output:
1
Example notes
The answers are 6, 3, and 1; in the second example, development and integration run in parallel, so 2 and 3 must not be added.
Editorial
Loading solution…