- 作业调度方案
- 2013-10-06 10:54:21 @
var
a:array[1..400]of longint;
pre,t:array[1..20]of longint;
place,time:array[1..20,1..20]of longint;
gc:array[1..20,-1..21,1..2]of longint;
m,n,ans:longint;
procedure init;
var i,j:longint;
begin
readln(m,n);
for i:=1 to m*n do read(a[i]);
readln;
for i:=1 to n do
begin
for j:=1 to m do read(place[i,j]);
readln;
end;
for i:=1 to n do
begin
for j:=1 to m do read(time[i,j]);
readln;
end;
end;
function max(a,b:longint):longint;
begin
if a>b then exit(a) else exit(b);
end;
procedure swap(var a,b:longint);
var c:longint;
begin
c:=a; a:=b; b:=c;
end;
procedure put(s,x,y:longint);
var i,j,k:longint;
begin
if gc[y,0,1]=0 then
begin
inc(gc[y,0,1]);
gc[y,1,1]:=pre[s];
gc[y,1,2]:=pre[s]+x;
pre[s]:=pre[s]+x;
if gc[y,gc[y,0,1],2]>ans then ans:=gc[y,gc[y,0,1],2];
exit;
end;
for i:=1 to gc[y,0,1] do
begin
if( gc[y,i-1,2]>=pre[s]) and (gc[y,i,1]-gc[y,i-1,2]>=x) then
begin
inc(gc[y,0,1]);
gc[y,gc[y,0,1],1]:=gc[y,i-1,2];
gc[y,gc[y,0,1],2]:=gc[y,i-1,2]+x;
pre[s]:=gc[y,i-1,2]+x;
for j:=1 to gc[y,0,1]-1 do
for k:=j+1 to gc[y,0,1] do
if gc[y,j,1]>gc[y,k,1] then
begin
swap(gc[y,j,1],gc[y,k,1]);
swap(gc[y,j,2],gc[y,k,2]);
end;
if gc[y,gc[y,0,1],2]>ans then ans:=gc[y,gc[y,0,1],2];
exit;
end else
if (gc[y,i-1,2]<pre[s]) and (gc[y,i,1]-pre[s]>=x) then
begin
inc(gc[y,0,1]);
gc[y,gc[y,0,1],1]:=pre[s];
gc[y,gc[y,0,1],2]:=pre[s]+x;
pre[s]:=pre[s]+x;
for j:=1 to gc[y,0,1]-1 do
for k:=j+1 to gc[y,0,1] do
if gc[y,j,1]>gc[y,k,1] then
begin
swap(gc[y,j,1],gc[y,k,1]);
swap(gc[y,j,2],gc[y,k,2]);
end;
if gc[y,gc[y,0,1],2]>ans then ans:=gc[y,gc[y,0,1],2];
exit;
end;
end;
inc(gc[y,0,1]);
gc[y,gc[y,0,1],1]:=max(gc[y,gc[y,0,1]-1,2],pre[s]);
gc[y,gc[y,0,1],2]:=max(gc[y,gc[y,0,1]-1,2],pre[s])+x;
pre[s]:=max(gc[y,gc[y,0,1]-1,2],pre[s])+x;
if gc[y,gc[y,0,1],2]>ans then ans:=gc[y,gc[y,0,1],2];
end;
procedure work;
var i:longint;
begin
ans:=0;
for i:=1 to n*m do
begin
inc(t[a[i]]);
put(a[i],time[a[i],t[a[i]]],place[a[i],t[a[i]]]);
end;
writeln(ans);
end;
begin
init;
work;
end.
5 条评论
-
woshiniaocai LV 7 @ 2015-03-17 20:07:19
!Hi(javascript:alert('Hello'))
-
2014-11-02 21:33:24@
!Hi(javascript:alert('Hello'))
-
2014-09-06 09:21:42@
把readln去掉就可以了
-
2013-10-25 18:10:57@
Vijos人比较多要不再来一次
!Hi(javascript:alert('Hello')) -
2013-10-06 21:45:44@
您好,Vijos为优质OJ,请您自己检查您的程序。
感谢您对Vijos的支持! 祝您刷题愉快!
- 1