1 条题解

  • 0
    @ 2025-9-10 0:08:19

    Pascal :

    var i,j,t1,t2,m,n,x:longint;a,b:array[1..100] of integer;  c:array[0..100] of boolean;
    begin
        readln(n,m);
        for i:=1 to n do
      
            read(a[i]);
      
        for i:=1 to m do
      
            read(b[i]);
      
             c[1]:=true;
            for i:=1 to n do
            begin
      
        t1:=t1+a[i];
        if (i mod 2=1) and (a[i]=1) and(x<15)then inc(x);
        if (x=15) and (c[a[i]-1]=true) then c[a[i]]:=true;
      
            end;
            if a[n]=0 then inc(t2,4)
            else
        begin
                    if x< 15 then
                    begin
                            if (n mod 2=1) and (a[n]<>1) or(n mod 2=0) and (a[n]=1)
                            then begin dec(t1,a[n]);if a[n]<4 then inc(t2,4)
                            else inc(t2,a[n]);end;
                    end
                    else
                    begin
                            if (c[a[n]-1]=false)and(a[n-1]<>1) then begin dec(t1,a[n]);
                            if a[n]<4 then inc(t2,4) else inc(t2,a[n]);end;
                    end;
      
            end;
      
      
             for i:=1 to m do
            begin
      
        t2:=t2+b[i];
        if (i mod 2=1) and (b[i]=1) and(x<15)then inc(x);
        if (x=15) and (c[b[i]-1]=true) then c[b[i]]:=true;
      
            end;
            if b[m]=0 then inc(t1,4)
            else
        begin
                    if x< 15 then
                    begin
                            if (m mod 2=1) and (b[m]<>1) or(m mod 2=0) and (b[m]=1)
                            then begin dec(t2,b[m]);if b[m]<4 then inc(t1,4)
                            else inc(t1,b[m]);end;
                    end
                    else
                    begin
                            if (c[b[m]-1]=false)and(b[m-1]<>1) then begin dec(t2,b[m]);
                            if b[m]<4 then inc(t1,4) else inc(t1,b[m]);end;
                    end;
      
            end;
      
      
    writeln(t1,' ',t2);
    end.
      
    
    • 1

    信息

    ID
    2722
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者