Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

常数卡的飞起 OTTTTTZ

Posted by Hoblovski at 2014-06-04 21:48:12 on Problem 1742 and last updated at 2014-06-04 21:48:45
{$OPTIMIZATION ON}
program poj1742;

const maxn=117;
      maxm=100017;

var f:array[0..maxm] of boolean;
    t:array[0..maxm] of longint;
    v,c:array[0..maxn] of longint;
    n,m:longint;

function init:boolean;
var i:longint;
begin
readln(n,m); if (n=0)and(m=0) then exit(false);
for i:=1 to n do read(v[i]);
for i:=1 to n do read(c[i]);
readln; exit(true);
end;

function dp:longint;
var i,j:longint;
begin
fillchar(f,sizeof(f),false); f[0]:=true;
for i:=1 to n do begin
        fillchar(t,sizeof(t),0); for j:=v[i] to m do
                if (not f[j])and(f[j-v[i]])and(t[j-v[i]]<c[i]) then begin
                        f[j]:=true;
                        t[j]:=t[j-v[i]]+1;
                end;
end; dp:=0; for i:=1 to m do inc(dp,byte(f[i]));
end;

begin
while init do writeln(dp);
end.
思想应该从代码里面容易看懂
开了外挂(参见某编译开关)都是 1300+ms
P党用这个程序对拍一下,慢3倍就完全没希望了.
啊,程序运行的时间可以用dos库里的gettime搞

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator