Problem L
Rerouting Rapids
The famous East Manitoba river that flows through Edmonton
consists of
Unfortunately, there have been many collisions lately in
rapids that have many other rapids feeding into them, as many
visitors may enter the same rapid at similar times, each being
fed into it by a different rapid. You work for the City of
Edmonton and have been tasked with rerouting some rapids to
decrease the rate of collisions. If it’s possible for a visitor
to start at some rapid
You wish to reroute rapids in this manner to minimize the maximum number of rapids feeding into any given rapid. Report this minimum number.
![\includegraphics[scale=0.5]{rapids.pdf}](/problems/reroutingrapids/file/statement/en/img-0001.png)
Input
The first line of input contains one integer
Output
Output the minimum possible highest number of rapids feeding into any given rapid, subject to rerouting as described above.
Sample Input 1 | Sample Output 1 |
---|---|
5 2 0 2 2 2 |
4 |
Sample Input 2 | Sample Output 2 |
---|---|
5 0 1 2 2 2 |
2 |