您的位置:首页 > 其它

USACO 1.2-Milking Cows

2010-06-17 13:45 309 查看
题目:Milking Cows

我是用的简单的模拟,总之先AC了。

{
ID:asdcyt01
PROB:milk2
LANG:PASCAL
}
program milk2(input,output);
var
n,i,j,b,e:longint;
count1,count2,maxn,minn,max,max2:longint;
a:array[1..1000000]of boolean;
begin
assign(input,'milk2.in');reset(input);
assign(output,'milk2.out');rewrite(output);
readln(n);
maxn:=1;minn:=maxlongint;
fillchar(a,sizeof(a),false);
for i:=1 to n do
begin
readln(b,e);dec(e);
for j:=b to e do a[j]:=true;
if e>maxn then maxn:=e;
if b<minn then minn:=b;
end;
count1:=0;count2:=0;max:=0;max2:=0;
for i:=minn to maxn do
begin
if not a[i] then inc(count1)
else
begin
if count1>max then max:=count1;
count1:=0;
end;
if a[i] then inc(count2)
else
begin
if count2>max2 then max2:=count2;
count2:=0;
end;
end;
if count2>max2 then max2:=count2;
writeln(max2,' ',max);
close(input);close(output);
end .
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: