Why I got "Wrang Answer"???? Послано qwt 3 мар 2002 08:07 var a:array[1..100,1..3] of longint; x:array[1..100] of longint; t,n,i,j,k,now:longint; begin readln(n); for i:=1 to n do begin x[i]:=i; readln(a[i,1],a[i,2],a[i,3]); end; for i:=1 to n-1 do for j:=i+1 to n do if a[x[i],1]>a[x[j],1] then begin k:=x[i]; x[i]:=x[j]; x[j]:=k; end; t:=0;now:=a[x[1],1]; for i:=1 to n do begin if now<a[x[i],1] then now:=a[x[i],1]; inc(now,a[x[i],2]); if now>a[x[i],3] then begin inc(t,now-a[x[i],3]); now:=a[x[i],3]; end; end; writeln(t); end. Re: Why I got "Wrang Answer"???? > var > a:array[1..100,1..3] of longint; > x:array[1..100] of longint; > t,n,i,j,k,now:longint; > begin > readln(n); > for i:=1 to n do begin > x[i]:=i; > readln(a[i,1],a[i,2],a[i,3]); > end; > for i:=1 to n-1 do for j:=i+1 to n do > if a[x[i],1]>a[x[j],1] then begin > k:=x[i]; > x[i]:=x[j]; > x[j]:=k; > end; > t:=0;now:=a[x[1],1]; > for i:=1 to n do begin > if now<a[x[i],1] then now:=a[x[i],1]; > inc(now,a[x[i],2]); > if now>a[x[i],3] then begin > {inc(t,now-a[x[i],3]);} -> t is max of different beetween now and a[x[i],3] not sum of different. > {now:=a[x[i],3]; } -> now is still remain, don't change it. > end; > end; > writeln(t); > end.
|