Description
ZXC received a task-to save the world. Fortunately, he has n fans, zxc the world into N parts, each fan handles a part, and finally he comes to the end. It is known how much time each fan takes to process each part, and what is the shortest time to save the world. Everyone starts at the same time, but can't help each other. This means that each fan can handle only one part, and must handle one.
Input Format
The first line, an integer n, represents the number of ZXC fans. Next n rows, n integers per line. Line I+1, the number of J indicates the time required for Part I fan section J.
Output Format
An integer that represents the minimum time required.
Sample Input
3 1 10 100 10 4 3 4 3 1
Sample Output
3
Hint
20% of data Meet 1<=n<=25;
100% of the data meets 1<=n<=800 and the minimum required time is no more than 10^9.
Analysis: See the topic first thought is to find the perfect match with Hungary, but also requires the least time, because everyone's work is separate, non-interference, so that the least time is to let people use the most time you least, two points enumerated the answer to determine whether you can find the perfect match on the line.
Code:
1#include <cstdio>2#include <cstring>3 4 intN, M, t[ +][ +];5 intvis[ +], from[ +];6 intto[1000000], nxt[1000000], first[ +], en;7 8 intINS (intP1,intp2)9 {Tenen++; OneTo[en] =P2; ANxt[en] =FIRST[P1]; -FIRST[P1] =en; - } the - intDraw (intLim) - { -Memset (To,0,sizeof(to)); +memset (NXT,0,sizeof(NXT)); -memset (First,0,sizeof(first)); +En =0; A for(inti =1; I <= N; i++) at for(intj =1; J <= N; J + +) - if(T[i][j] <=Lim) Ins (i, j); - } - - BOOLFind (inta) - { in - for(inte = First[a]; E E =Nxt[e]) to { + if(!Vis[to[e]]) - { theVis[to[e]] =1; * if( from[To[e]] = =-1|| Find ( from[To[e]])) $ {Panax Notoginseng from[To[e]] =A; - return true; the } + } A } the return false; + } - $ BOOLWork () $ { - intAns =0; -memset ( from, -1,sizeof( from)); the for(inti =1; I <= N; i++) - {Wuyimemset (Vis,0,sizeof(Vis)); theAns + =find (i); - } Wu returnAns = =N; - } About $ intRun () - { - intL =1, r =m, mid; - while(L <R) A { +Mid = (L + r) >>1; the Draw (mid); - if(Work ()) R =mid; $ ElseL = mid +1; the } the returnR; the } the - intMain () in { thescanf ("%d", &n); m =0; the for(inti =1; I <= N; i++) About for(intj =1; J <= N; J + +) thescanf ("%d", &T[i][j]), theT[i][j] > m? m = T[i][j]:0; theprintf ("%d", run ()); +}
PS: It seems that every time there will be many sides, in fact, the two points down is not much, with the adjacency matrix ran a total of 17.772s, with the adjacency table only ran 3.93s. (N+e only used 1.285s,orzorz)
"Yzoj 1060" assignment work