比赛 20101117 评测结果 WWWWWWWWWW
题目名称 教官 最终得分 0
用户昵称 mate 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-11-17 11:10:22
显示代码纯文本
program coolboy;
var n,c1,c2,c3,i,max:longint;
    a,b:array[1..35000]of longint;
begin
assign(input,'officer.in');reset(input);   
assign(output,'officer.out');rewrite(output);   
read(n);
for i:=1 to n do
begin
   read(a[i]);
   if a[i]=1 then begin b[i]:=c1+1;c1:=b[i];end;
   if a[i]=2 then
    begin
    if c1>c2 then begin b[i]:=c1+1;c2:=b[i] end
     else begin b[i]:=c2+1;c2:=b[i];end;
    end;
   if a[i]=3 then
    begin
    if c1>c2 then
     begin
      if c1>c3 then begin b[i]:=c1+1;c3:=b[i];end
       else begin b[i]:=c3+1;c3:=b[i];end;
     end
     else
     begin
      if c2>c3 then begin b[i]:=c2+1;c3:=b[i];end
       else begin b[i]:=c3+1;c3:=b[i];end;
     end;
    end;
end;
max:=0;
for i:=1 to n do if b[i]>max then max:=b[i];
for i:=1 to n do b[i]:=0;c1:=0;c2:=0;c3:=0;
for i:=n downto 1 do
begin
   if a[i]=1 then begin b[i]:=c1+1;c1:=b[i];end;
   if a[i]=2 then
    begin
    if c1>c2 then begin b[i]:=c1+1;c2:=b[i] end
     else begin b[i]:=c2+1;c2:=b[i];end;
    end;
   if a[i]=3 then
    begin
    if c1>c2 then
     begin
      if c1>c3 then begin b[i]:=c1+1;c3:=b[i];end
       else begin b[i]:=c3+1;c3:=b[i];end;
     end
     else
     begin
      if c2>c3 then begin b[i]:=c2+1;c3:=b[i];end
       else begin b[i]:=c3+1;c3:=b[i];end;
     end;
    end;
end;
for i:=1 to n do if b[i]>max then max:=b[i];
writeln(n-max);
close(input);
close(output);

end.