12428 - Enemy at the Gates


Difficulty : easy

Solution Description :

Ad hoc, construct graph problem

Input n & m

if m<n then print m
Otherwise you need to calculate maximum number of critical roads

For calculating critical road see the example below
Here city=7 and roads = 12 then critical roads = 2 (which is colored by red)

image

You need to do this what is see in the example.
If n=10 and m=15 then critical road=5
If n=10 and m=16 then critical road=4
If n=10 and m=19 then critical road=4
If n=10 and m=20 then critical road=3