|
|
back to boardWhat problem it has? var t1,t2,t3:array[0..50] of longint; procedure qsort(l,r:longint); var i,j,x,put:longint; begin i:=l;j:=r;x:=t1[(i+j) shr 1]; repeat while x>t1[i] do inc(i); while x<t1[j] do dec(j); if i<=j then begin put:=t1[i];t1[i]:=t1[j];t1[j]:=put; put:=t2[i];t2[i]:=t2[j];t2[j]:=put; put:=t3[i];t3[i]:=t3[j];t3[j]:=put; inc(i);dec(j); end; until i>j; if i<r then qsort(i,r); if j>l then qsort(l,j); end; var n,i,temp,need:longint; begin readln(n); for i:=1 to n do readln(t1[i],t2[i],t3[i]); qsort(1,n); for i:=1 to n do begin t1[i]:=t1[i]-temp; if t1[i]<0 then t1[i]:=0; temp:=temp+t1[i]+t2[i]; if t3[i]<temp then need:=need+(temp-t3[i]); end; writeln(need); end. Wrong Answer TEST 10. |
|
|