比赛 Segment Tree Competition 评测结果 AATAAEEEE
题目名称 滑动窗口 最终得分 44
用户昵称 封自 运行时间 4.574 s
代码语言 Pascal 内存使用 1.16 MiB
提交时间 2016-08-28 19:59:56
显示代码纯文本
var m,n,i,j:longint;
	max,min,a:array[1..100001] of longint;

begin
assign(input,'window.in');reset(input);
assign(output,'window.out');rewrite(output);
	readln(n,m);
	for i:=1 to n do read(a[i]);
	for i:=1 to n do
	  begin
		max[i]:=-maxlongint;
		min[i]:=maxlongint;
	  end;
	for i:=1 to n-m+1 do 
	  for j:=0 to m-1 do 
		begin
		  if a[i+j]>=max[i] then max[i]:=a[i+j];
		  if a[i+j]<=min[i] then min[i]:=a[i+j];
		end;
	for i:=1 to n-m+1 do write(min[i],' ');
	writeln;
	for i:=1 to n-m+1 do write(max[i],' ');
close(input);close(output);
end.