| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:裸DP染色94msIn Reply To:Re:二进制47ms单调队列200+ms,搞什么东西啊 Posted by:cmdlinux at 2011-03-13 22:48:30 type
block=record h,a,c:longint; end;
var
b:array[0..400]of block;
f:array[0..40000]of boolean;
v:array[0..40000]of byte;
n,i,j:longint;
procedure qsort(l,r:longint);
var
i,j,x:longint;
y:block;
begin
i:=l;
j:=r;
x:=b[(l+r) div 2].a;
repeat
while b[i].a<x do inc(i);
while x<b[j].a do dec(j);
if not(i>j) then
begin
y:=b[i]; b[i]:=b[j]; b[j]:=y;
inc(i); dec(j);
end;
until i>j;
if l<j then qsort(l,j);
if i<r then qsort(i,r);
end;
begin
read(n);
for i:=1 to n do with b[i] do read(h,a,c);
qsort(1,n);
f[0]:=true;
for i:=1 to n do with b[i] do
begin
fillchar(v,sizeof(v),0);
for j:=0 to a-h do
if f[j] and(v[j]<c)and not f[j+h] then
begin
f[j+h]:=true;
v[j+h]:=v[j]+1;
end;
end;
for i:=b[n].a downto 0 do
if f[i] then begin writeln(i); break; end;
end.
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator