Who can help me? Here is my program(WA): var a:array[1..100,1..2]of longint; b:array[1..100]of longint; max,i,n,t1,j:longint; begin readln(n); for i:=1 to n do readln(a[i,1],b[i],a[i,2]); for i:=1 to n-1 do for j:=i+1 to n do if a[i,1]>a[j,1] then begin t1:=a[i,1];a[i,1]:=a[j,1];a[j,1]:=t1; t1:=a[i,2];a[i,2]:=a[j,2];a[j,2]:=t1; t1:=b[i];b[i]:=b[j];b[j]:=t1; end; max:=a[1,1]+b[1]; for i:=2 to n do if max<a[i,1] then max:=a[i,1]+b[i] else j:=max+b[i]; if j>a[n,2] then write(j-a[n,2]) else write(0); end. Re: Who can help me? Послано gc007 30 окт 2002 15:16 > Here is my program(WA): > var > a:array[1..100,1..2]of longint; > b:array[1..100]of longint; > max,i,n,t1,j:longint; > > begin > readln(n); > for i:=1 to n do readln(a[i,1],b[i],a[i,2]); > for i:=1 to n-1 do > for j:=i+1 to n do > if a[i,1]>a[j,1] then > begin > t1:=a[i,1];a[i,1]:=a[j,1];a[j,1]:=t1; > t1:=a[i,2];a[i,2]:=a[j,2];a[j,2]:=t1; > t1:=b[i];b[i]:=b[j];b[j]:=t1; > end; > max:=a[1,1]+b[1]; > for i:=2 to n do > if max<a[i,1] then max:=a[i,1]+b[i] else j:=max+b[i]; > if j>a[n,2] then write(j-a[n,2]) else write(0); > end. > Tao Zhang is really a fool,a cheater. Послано gc007 30 окт 2002 15:17 > Here is my program(WA): > var > a:array[1..100,1..2]of longint; > b:array[1..100]of longint; > max,i,n,t1,j:longint; > > begin > readln(n); > for i:=1 to n do readln(a[i,1],b[i],a[i,2]); > for i:=1 to n-1 do > for j:=i+1 to n do > if a[i,1]>a[j,1] then > begin > t1:=a[i,1];a[i,1]:=a[j,1];a[j,1]:=t1; > t1:=a[i,2];a[i,2]:=a[j,2];a[j,2]:=t1; > t1:=b[i];b[i]:=b[j];b[j]:=t1; > end; > max:=a[1,1]+b[1]; > for i:=2 to n do > if max<a[i,1] then max:=a[i,1]+b[i] else j:=max+b[i]; > if j>a[n,2] then write(j-a[n,2]) else write(0); > end. > |