记录编号 |
27758 |
评测结果 |
AAWAWAAWAW |
题目名称 |
垃圾陷阱 |
最终得分 |
60 |
用户昵称 |
weichen |
是否通过 |
未通过 |
代码语言 |
Pascal |
运行时间 |
0.003 s |
提交时间 |
2011-09-29 15:57:16 |
内存使用 |
0.12 MiB |
显示代码纯文本
program lx;
var
f,g:array[0..100]of longint;
hpf,hpg:array[0..100]of longint;
d,g1,i,j,m,n,sum,die:longint;
t,life,h:array[0..100]of longint;
function max(a,b:longint):longint;
begin
if a>b then max:=a
else max:=b;
end;
begin
//**********************************************************
assign(input,'well.in');
reset(input);
assign(output,'well.out');
rewrite(output);
//******************** chu shi hua *************************
readln(d,g1);
t[0]:=0;
for i:=1 to g1 do
readln(t[i],life[i],h[i]);
hpf[0]:=10; hpg[0]:=10;
//************************* d p ********************
for i:=1 to g1 do
if (hpg[i-1]>=t[i])or(hpf[i-1]>=t[i]) then
begin
if hpg[i-1]>=t[i] then n:=g[i-1]+h[i]
else n:=g[i-1];
if hpf[i-1]>=t[i] then m:=f[i-1]+h[i]
else m:=f[i-1];
if m>n then begin
f[i]:=m;
if m=f[i-1]+h[i] then hpf[i]:=hpf[i-1]
else hpf[i]:=hpf[i-1]+life[i];
end
else begin
f[i]:=n;
if n=g[i-1]+h[i] then hpf[i]:=hpg[i-1]
else hpf[i]:=hpg[i-1]+life[i];
end;
g[i]:=max( f[i-1],g[i-1] );
if f[i-1]<g[i-1] then hpg[i]:=hpg[i-1]+life[i]
else hpg[i]:=hpf[i-1]+life[i];
sum:=max( f[i],g[i] );
if sum>=d then break;
end;
//****************** zheng li shu chu**********************
sum:=max( f[g1],g[g1]);j:=-1;
if i<g1 then write(t[i])
else if sum>=d then write(t[g1])
else j:=1;
if j=1 then
begin
sum:=10;
for i:=1 to g1 do
inc(sum,life[i]);
write(sum);
end;
//**********************************************************\
close(input);
close(output);
end.