评测不出来,不知道会不会超时

// program houshaochibi;
var i,n,j,long:longint;
    a,b:array[1..100000]of longint;
begin
read (n);long:=0;
for i:= 1 to n do
read(a[i],b[i]);
for i:= 1 to n do
    for j:= i to n do
    begin
        if (a[j]<b[i]) and (b[j]>b[i]) and(a[j]>a[i])
        then begin
        b[i]:=b[j];
        a[j]:=b[j];
        end;
        if (a[j]<a[i]) and (b[j]<b[i]) and(b[j]>a[i])
                then begin
                a[i]:=a[j];
                b[j]:=a[j];
            end;
        end;
for i:= 1 to n do
long:=long+(b[i]-a[i]);
writeln(long);
end.

0 条评论

目前还没有评论...

信息

ID
1165
难度
6
分类
模拟 点击显示
标签
递交数
3240
已通过
940
通过率
29%
被复制
14
上传者