Thứ Ba, 3 tháng 5, 2022

CUUCHUOI PASCAL

var p1,p2,s,gia,x,n,i,p3:longint;

function max(x,y:longint):longint;
begin
    if x>y then exit(x)
    else exit(y);
end;

procedure giai;
begin
    readln(n);
    readln(x);
    s:=0;
    for i:=1 to n do
    begin
        readln(p1,p2);
        if abs(p1-p2)<=x then gia:=max(p1,p2)
        else
        begin
            read(p3);
            gia:=p3;
        end;
        s:=s+gia;
    end;
    writeln(s);
end;

begin
    assign(input,'cuuchuoi.inp');reset(input);
    assign(output,'cuuchuoi.out');rewrite(output);
    giai;
end.

Không có nhận xét nào:

Đăng nhận xét

Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.