记录编号 49499 评测结果 AAAAAAAAAA
题目名称 [東方S1] 琪露诺 最终得分 100
用户昵称 GravatarAbel·S 是否通过 通过
代码语言 Pascal 运行时间 0.126 s
提交时间 2012-11-08 11:46:40 内存使用 7.79 MiB
显示代码纯文本
program cojs_p920;
var
	pos,q,a,f,next:array[0..400000] of longint;
	i,j,k,l,r,m,n,he,ta:longint;
procedure ass;
begin
	assign(input,'iceroad.in');
	assign(output,'iceroad.out');
	reset(input);
	rewrite(output);
end;
procedure cls;
begin
	close(input);
	close(output);
end;
procedure init;
var
	i:longint;
begin
	ass;
	readln(n,l,r);
	for i:=0 to n do
		read(a[i]);
	readln;
	fillchar(f,sizeof(f),0);
	fillchar(next,sizeof(next),0);
end;
begin
	init;
	f[n+1]:=0;
	he:=0;
	ta:=0;
	for i:=n+l downto n+1 do
		f[i]:=-1;
	q[0]:=0;
        pos[0]:=-1;
	for i:=n downto 0 do
	begin
		if q[ta]<=f[i+l] then begin
		        while (q[ta]<=f[i+l])and (ta>=he) do dec(ta);
		                inc(ta);
		        q[ta]:=f[i+l]; pos[ta]:=i+l;
                end;
		while pos[he]>i+r do
			inc(he);
        f[i]:=q[ta];
		next[i]:=pos[ta];
		inc(f[i],a[i]);
	end;
	writeln(f[0]);
	write('0',' ');
	i:=0;
	repeat
		write(next[i],' ');
		i:=next[i];
	until i=-1;
	cls;
end.