用户ID: 密码: 验证:

登 录

注 册 取回密码

中山教育

中山国际网

中国教育在线

时代财富科技公司 FortuneAge Technology Co., Ltd. 校园博客客服网站(新)

我的资料

Mpq

博客信息

积分:988
等级:4级 lv 4
日志总数:231
发表评论总数:18 ( 查看)
获得评论总数:21
发表留言总数:0
所属学校:三鑫
收藏本站:

最新公告

欢迎光临我的博客!

最新相册

我的日历

最新评论

--游客
好文好文,是您的手笔?如果是您的文章,如果您愿意和我联系,...
还有就是数学不能使用计算器…….......在读初中之前原...
--Mpq
这次似乎不举行冬季长跑……看来在三鑫参加的体育项目最终是以...
--Mpq
看了你的"总结", 挺有针对性的! 相信下学期你一定会有...

RSS


首页 -> 其他题的题库->Job Assignment
Job Assignment

                         Job Assignment
    One problem comes up when we are trying to assign jobs about GDCPC'2003 to staffs. Because some of them complain that the tasks assigned to them are so bother. This emotion will lead to very bad effect in sequence. So we try to satisfy every staff as possible as we can. At first , we make an investigation to get the information about staffs' attitude towards every task. And then we evaluate each attitude as a point (a positive integer number not larger than 100). The higher the point is , the more the staff is satisfied. Because the staffs are very busy. they have only a little leisure time to finish the task. So we just assign one task to one person, of course , one task can not be assigned to different persons. Now we give you all the points and hope you can help us to assign the tasks to make the sum of the points which correspond the assignment is maximum.

Input
  Input will contain several test case.The first line of each test case only contains one integer number n(1<=n<=100). N is the number of staffs also is the number of tasks. and then , the following N lines describe staffs's attitude. each line contains n positive integer nmbers. the jth number in the ith line describes ith staff's attitude to the jth task

Output
  for each test case you shold output one line, and just one number in this line. the number is the maximum

Sample Input:
2
10 90
80 100
3
50 60 70
70 75 80
80 90 100
0

Sample Output
170
230
 
 
 

Program Assign_Mpq;

Const Maxn=100;

var
  n,Answer:longint;
  lx,ly:array[1..Maxn] of integer;
  sx,sy:array[1..Maxn] of boolean;
  cx,cy:array[1..Maxn] of integer;
  g:array[1..Maxn,1..Maxn] of integer;

procedure init;
var
  i,j:integer;
begin
  for i:=1 to n do
  begin
    for j:=1 to n do read(g[i,j]);
    readln;
  end;
end;

function Find(k:integer):boolean;
var
  i:integer;
begin
  sx[k]:=true;
  for i:=1 to n do
    if (Not sy[i]) and (lx[k]+ly[i]=g[k,i]) then
    begin
      sy[i]:=true;
      if (cy[i]=0) or (Find(cy[i])) then
      begin
        cx[k]:=i;
        cy[i]:=k;
        exit(true);
      end;
    end;
  exit(false);
end;

procedure KM;
var
  i,j,k,Min:integer;
begin
  fillchar(lx,sizeof(lx),0);
  fillchar(ly,sizeof(ly),0);
  fillchar(cx,sizeof(cx),0);
  fillchar(cy,sizeof(cy),0);
  for i:=1 to n do
    for j:=1 to n do
      if lx[i]<g[i,j] then
        lx[i]:=g[i,j];

  for k:=1 to n do
    if cx[k]=0 then
      while true do
      begin
        fillchar(sy,sizeof(sy),0);
        fillchar(sx,sizeof(sx),0);
        if Find(k) then break;
        Min:=Maxint;
        for i:=1 to n do
          if sx[i] then
            for j:=1 to n do
              if Not sy[j] then
                if (lx[i]+ly[j]-g[i,j]<Min) then Min:=lx[i]+ly[j]-g[i,j];

       for i:=1 to n do
          if sx[i] then dec(lx[i],Min);
        for i:=1 to n do
          if sy[i] then inc(ly[i],Min);
      end;

  Answer:=0;
  for i:=1 to n do
    inc(Answer,g[i,cx[i]]);
  writeln(Answer);
end;

begin
assign(input,'Assign.in'); reset(input);
assign(output,'Assign.out'); rewrite(output);
  readln(n);
  while n<>0 do
  begin
    init;
    KM;
    readln(n);
  end;
close(input); close(output);
end.

 
 

网友评论

共 0 页,0 条记录  

用户名:
密码:
您的评论:
正在载入编辑器...
请输入验证码:


发 表 评 论

Mpq-中山教师家园