比赛 20101117 评测结果 WWWWWWWWWW
题目名称 教官 最终得分 0
用户昵称 reamb 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-11-17 10:01:46
显示代码纯文本
program jiaoguan;
var
  n,i,j,w,jilu,t,q:longint;
  biaozhi:boolean;
  qian,hou:array[0..10001]of longint;
procedure shanchu(k:longint);
begin
  t:=0;
  q:=0;
  repeat
    t:=t+1;
    q:=hou[q]
  until t=k;
  jilu:=q;
  hou[qian[q]]:=hou[q];
  qian[hou[q]]:=qian[q]
end;
procedure charu(k:longint);
begin
  t:=0;
  q:=0;
  repeat
    t:=t+1;
    q:=hou[q]
  until t=w;
  qian[jilu]:=qian[q];
  hou[jilu]:=hou[qian[q]];
  hou[qian[q]]:=jilu;
  qian[q]:=jilu;
end;
procedure panduan;
begin
  t:=0;
  q:=0;
  repeat
    t:=t+1;
    if hou[q]<>t then
    begin
      biaozhi:=false;
      exit
    end ;
    q:=hou[q]
  until q=n+1;
end;
begin
  assign (input,'officer.in');
  reset (input);
  assign (output,'officer.out');
  rewrite (output);
    readln (n);
    for i:=1 to n do
    begin
      qian[i]:=i-1;
      hou[i]:=i+1
    end;
    qian[0]:=0;
    hou[0]:=1;
    qian[n+1]:=n;
    hou[n+1]:=n+1;
    for i:=1 to n do
    begin
      readln (w);
      shanchu(i);
      charu(w);
      biaozhi:=true;
      panduan;
      if biaozhi then
      begin
        writeln (i);
        break
      end
    end;
  close (input);
  close (output)
end.