比赛 20101025 评测结果 AWWWWWWWWW
题目名称 逛街 最终得分 10
用户昵称 maxiem 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-10-25 21:43:10
显示代码纯文本
  1. program shop;
  2. var
  3. data:array [1..300] of record
  4. w,v,t,h:longint;
  5. end;
  6. f:array [0..1000,0..100] of longint;
  7. cut:array [1..100000] of record
  8. x,y:longint;
  9. end;
  10. value,a1,b1,a2,b2,top,i,j,n,x,y:longint;
  11. begin
  12. fillchar (f,sizeof(f),$FF);
  13. fillchar (data,sizeof(data),0);
  14. fillchar (cut,sizeof(cut),0);
  15. assign (input,'shop.in');
  16. reset (input);
  17. readln (n,x,y);
  18. for i:=1 to n do with data[i] do readln (w,v,t,h);
  19. close (input);
  20. assign (output,'shop.out');
  21. rewrite (output);
  22. top:=1;cut[top].x:=0;cut[top].y:=0;
  23. f[0,0]:=0;
  24. for i:=1 to n do begin
  25. for j:=1 to top do begin
  26. a1:=cut[j].x+data[i].w;b1:=cut[j].y+data[i].v;
  27. a2:=cut[j].x+data[i].w*data[i].h;b2:=cut[j].y+data[i].v*data[i].h;
  28. if (a1<=x) and (b1<=y) then begin
  29. value:=f[cut[j].x,cut[j].y]+data[i].t;
  30. if f[a1,b1]=-1 then begin
  31. inc (top);
  32. cut[top].x:=a1;cut[top].y:=b1;
  33. f[a1,b1]:=value;
  34. end
  35. else if value>f[a1,b1] then f[a1,b1]:=value;
  36. end;
  37. if (a2<=x) and (b2<=y) then begin
  38. value:=f[cut[j].x,cut[j].y]+data[i].t*data[i].h;
  39. if f[a2,b2]=-1 then begin
  40. inc(top);
  41. cut[top].x:=a2;cut[top].y:=b2;
  42. f[a2,b2]:=value;
  43. end
  44. else if value>f[a2,b2] then f[a2,b2]:=value;
  45. end;
  46. end;
  47. end;
  48. writeln (f[x,y]);
  49. close (output);
  50. end.