记录编号 |
79028 |
评测结果 |
AAAAAAAAAAA |
题目名称 |
[USACO Feb08] 麻烦的聚餐 |
最终得分 |
100 |
用户昵称 |
毕之 |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.034 s |
提交时间 |
2013-11-04 22:29:45 |
内存使用 |
0.28 MiB |
显示代码纯文本
var
a,b:array[0..30000,1..3]of integer;
x,i,j,k,n,jie:integer;
function min(a,b:integer):integer;
begin
if a<=b then exit(a) else exit(b);
end;
begin
assign(input,'egroup.in');reset(input);
assign(output,'egroup.out');rewrite(output);
readln(n);
fillchar(a,sizeof(a),$7F);fillchar(b,sizeof(b),$7F);
for i:=1 to 3 do
begin
a[0,i]:=0;b[0,i]:=0;
end;
for i:=1 to n do
begin
readln(x);
for j:=1 to 3 do
for k:=1 to j do
begin
if j=x then a[i,j]:=min(a[i-1,k],a[i,j])
else a[i,j]:=min(a[i-1,k]+1,a[i,j]);
end;
for j:=1 to 3 do
for k:=j to 3 do
begin
if j=x then b[i,j]:=min(b[i-1,k],b[i,j])
else b[i,j]:=min(b[i-1,k]+1,b[i,j]);
end;
end;
jie:=32767;
for i:=1 to 3 do
begin
if a[n,i]<jie then jie:=a[n,i];
if b[n,i]<jie then jie:=b[n,i];
end;
writeln(jie);
close(input);close(output);
end.