比赛 |
20110928 |
评测结果 |
AWWAWWWWWW |
题目名称 |
垃圾陷阱 |
最终得分 |
20 |
用户昵称 |
weichen |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2011-09-28 21:34:15 |
显示代码纯文本
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] then
begin
n:=g[i-1]+h[i];
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;
hpf[i]:=hpf[i-1];
end
else begin
f[i]:=n;
hpf[i]:=hpg[i-1];
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 for j:=g1 downto 1do
if g[j]<>0 then break;
if j<>-1 then
begin
sum:=10;
for i:=1 to j do
inc(sum,life[i]);
write(sum);
end;
//**********************************************************\
close(input);
close(output);
end.