记录编号 75569 评测结果 AAAAAWW
题目名称 [NOI 1998]免费馅饼 最终得分 71
用户昵称 Gravatargungnir 是否通过 未通过
代码语言 Pascal 运行时间 0.006 s
提交时间 2013-10-28 12:00:41 内存使用 0.60 MiB
显示代码纯文本
var
w,h,e,t,c,v,r:longint;
a:array[-5..1020,-5..105]of longint;


function extract(t,c:longint):longint;
var nc,bnc:longint;
begin
bnc:=c-2;
for nc:=c-1 to c+2 do
if a[t,nc]>a[t,bnc] then bnc:=nc;
extract:=bnc;
end;

procedure collect;
var i,j:longint;
begin
 for i:=e-1 downto 0 do
 for j:=1 to w do
 inc(a[i,j],a[i+1,extract(i+1,j)]);
end;

procedure solution;
var nc,c,s:longint;
begin
 c:=(1+w)div 2;
 s:=a[0,c];
 writeln(s);
 for t:=0 to e-1 do
 begin
 nc:=extract(t+1,c);
 s:=a[t+1,nc];
 if s=0 then break;
 writeln(nc-c);
 c:=nc;
 end;
end;



begin
assign(input,'freepizza.in');reset(input);
assign(output,'freepizza.out');rewrite(output);
fillchar(a,sizeof(a),0);
readln(w,h);
e:=0;
while not eof do
begin
readln(t,c,v,r);
if((h-1)mod v =0)then
begin
inc(t,(h-1)div v);
inc(a[t,c],r);
if t>e then e:=t;
end;
end;

collect;
solution;
close(input);close(output);
end.