比赛 noip_6 评测结果 AAAWAA
题目名称 打保龄球 最终得分 83
用户昵称 lc 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-10-08 21:27:08
显示代码纯文本
program noip5_1;
 var
     s:string;
     lk:integer;
     ans:array[0..12] of integer;
     score:array[1..14] of record
       one,two:integer;
       end;

procedure init;
 var
    i:integer;
    st:string;
 begin
  fillchar(score,sizeof(score),$FF);
  readln(s);  s:=s+' ';
  st:='';  lk:=0;
   for i:=1 to length(s) do
     if (s[i]<>' ')
     then st:=st+s[i]
      else begin
           inc(lk);
           if st[1]='/' then begin
                            score[lk].one:=10;
                            score[lk].two:=-1
                            end
                       else begin
                            score[lk].one:=ord(st[1])-48;
                            if st[2]='/' then score[lk].two:=10-score[lk].one
                                         else score[lk].two:=ord(st[2])-48
                            end;
           st:='';
           end;

 end;

procedure main;
 var
    i,len:integer;
 begin
  fillchar(ans,sizeof(ans),$FF);
  for i:=1 to 12 do
   begin
   if score[i].one=10
   then begin
        if score[i+1].two<>-1
        then ans[i]:=10+score[i+1].one+score[i+1].two
        else
            if (score[i+1].one<>-1) and (score[i+2].one<>-1)
            then ans[i]:=10+score[i+1].one+score[i+2].one;
        end
   else
       if score[i].one+score[i].two=10
       then begin
            if score[i+1].one<>-1
            then ans[i]:=10+score[i+1].one
            end
       else
            if (score[i].one<>-1) and (score[i].two<>-1)
            then ans[i]:=score[i].one+score[i].two;
   end;

  for i:=1 to 12 do
  if ans[i]=-1 then break;
  len:=i-1;
  for i:=1 to len-1 do
  write(ans[i],' ');
  writeln(ans[len]);
  ans[0]:=0;
  for i:=1 to len-1 do
   begin
   ans[i]:=ans[i-1]+ans[i];
   write(ans[i],' ');
   end;
  writeln(ans[len]+ans[len-1]);
 end;


begin
 assign(input,'bowling.in');
 assign(output,'bowling.out');
 reset(input); rewrite(output);
 init;
 main;
 close(input); close(output);
end.