| 比赛 | 
    20101101 | 
    评测结果 | 
    WWWWWWWWWW | 
    | 题目名称 | 
    漂亮字串 | 
    最终得分 | 
    0 | 
    | 用户昵称 | 
    reamb | 
    运行时间 | 
    0.000 s  | 
    | 代码语言 | 
    Pascal | 
    内存使用 | 
    0.00 MiB  | 
    | 提交时间 | 
    2010-11-01 21:34:40 | 
显示代码纯文本
program piaoliangzichuan;
var
  counto,countx,maxo,maxx,l:longint;
function min(a,b:longint):longint;
begin
  if a<b then
    min:=a
  else
    min:=b
end;
function max(a,b:longint):longint;
begin
  if a>b then
    max:=a
  else
    max:=b
end;
begin
  assign (input,'bs.in');
  reset (input);
  assign (output,'bs.out');
  rewrite (output);
    repeat
      readln (counto,countx,maxo,maxx);
      if counto=0 then
        writeln (min(countx,maxx))
        else
        if countx=0 then
          writeln (min(counto,maxo))
          else
          if maxo=0 then
            writeln (min(countx,maxx))
            else
            if maxx=0 then
              writeln (min(counto,maxo))
            else
            begin
              l:=2*min(counto,countx);
              if counto>countx then
                l:=l+min(counto,maxo);
              if countx>counto then
                l:=l+min(countx,maxx);
              if counto=countx then
                l:=l+max(min(counto,maxo),min(countx,maxx));
              writeln (l)
            end
    until eof;
  close (input);
  close (output)
end.