|
||||||||||
Load BalancingTime Limit: 2000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1212 Accepted Submission(s): 489 Special Judge Problem Description In the Wide Web World, Which web server was popular in web site? Apache, nginx, lighttpd? Baidu.com use Apache, and many web sites like 163.com use nginx. Why? Its configuration is very simple, and it has very powerful load balancing features. How does load balancing work? Load balancing is a technique to spread work between two or more computers in order to get optimal resource utilization, maximize throughput, and minimize response time. Wiskey very curious about this technology and he wants to build a simple load balancing model. He define the web site has M servers, and N jobs need be done. Each job has a processing time T; we seek to assign each job to one of the servers so that the loads placed on all servers are as "balanced" as possible. The "balanced" mean the Minimize it (max {TMi} - min {TMj}). TMi is the server i total time cost. But, as Wiskey Know, this scheduling problem of finding an assignment of minimum gap is NP-hard. Can you write a better load balancing than Wiskey? Challenge it~! Input The first integer C represents the number of cases, And C cases followed. Each test case contains a single integer N (1<=N<=100000) and M (1<=M<=100). The next N line contains integers, meaning the time of job T1, T2Tn. (1<=Ti<=1000000) Output For each test case, first output the N, and follows N numbers mean the job i assign to which server. The servers number count from 0. Sample Input
Sample Output
Hint Hint This problem is special judge, if your assign plan (max {TMi} -min {TMj}) <= my answer + 1000, it be consider Accept. Source | ||||||||||
|