⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 p1303.pas

📁 www.vijos.cn上一些习题的参考源码
💻 PAS
字号:
program missile;
const
	MAXN=1000;
var
	h,d:array[1..MAXN] of integer;
	i,j,k,n,best,best2:integer;
	c:char;
begin
	{readln(n);
	for i:=1 to n do
		readln(h[i]);}
	n:=0;
	k:=0;
	while not eoln do begin
		read(c);
		if c=',' then begin
			inc(n);
			h[n]:=k;
			k:=0;
			continue;
		end;
		k:=k*10+ord(c)-ord('0');
	end;
	inc(n);
	h[n]:=k;
	
	fillchar(d,sizeof(d),0);
	best:=0; 
	
	for i:=1 to n do begin
		d[i]:=1;
		for j:=1 to i-1 do begin
			if (h[j]>=h[i]) and (d[j]+1>d[i]) then begin
				d[i]:=d[j]+1;
			end;
		end;
		if d[i]>best then best:=d[i];
	end;	
	
	best2:=0;
	for i:=1 to n do begin
		d[i]:=1;
		for j:=1 to i-1 do begin
			if (h[j]<h[i]) and (d[j]+1>d[i]) then begin
				d[i]:=d[j]+1;
			end;
		end;
		if d[i]>best2 then best2:=d[i];
	end;
	writeln(best,',',best2-1);
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -