People and taxis are on the street. Enter people and car locations and calculate the shortest time for everyone to get on the bus.
Practice: HungaryAlgorithmDirectly...
# Include <cstdio> # include <cstring> # include <cmath> # include <algorithm> using namespace STD; const int LMT = 102; double gra [LMT] [LMT], chose [LMT * LMT], X [LMT <1], Y [LMT <1], have; int xnum, ynum, CNT, link [LMT]; bool vis [LMT]; bool DFS (int I) {for (Int J = 0; j <ynum; j ++) {If (GRA [I] [J] <= have &&! Vis [J]) {vis [J] = true; If (link [J] =-1 | DFS (link [J]) {link [J] = I; return true ;}} return false;} bool Hu (void) {memset (link,-1, sizeof (Link )); for (INT I = 0; I <xnum; I ++) {memset (VIS, 0, sizeof (VIS); If (! DFS (I) return 0;} return 1;} double solve (void) {int L = 0, r = cnt-1, M; double res = 0; while (L <= r) {int M = (L + r)> 1; Have = chose [m]; If (Hu () {res = have; R = m-1;} else l = m + 1;} return res;} int main () {Double V; int I; while (~ Scanf ("% d", & xnum, & ynum) {int I; CNT = 0; memset (GRA,-1, sizeof (GRA )); for (I = 0; I <xnum; I ++) scanf ("% lf", & X [I], & Y [I]); (; I <xnum + ynum; I ++) scanf ("% lf", & X [I], & Y [I]); scanf ("% lf ", & V); For (INT I = 0; I <xnum; I ++) for (Int J = 0; j <ynum; j ++) {gra [I] [J] = SQRT (X [I]-X [J + xnum]) * (X [I]-X [J + xnum]) + (Y [I]-y [J + xnum]) * (Y [I]-y [J + xnum])/V; chose [CNT ++] = gra [I] [J];} Sort (chose, chose + CNT); printf ("%. 2lf \ n ", solve ();} return 0 ;}