|
|
back to boardI had done my best but my program still be tle on test 14...need help... var n, m : longint; f : boolean; done : array[1..100] of boolean; put : array[1..100, 0..100] of longint; board : array[1..100] of longint; row, order : array[0..10] of longint; procedure sort; var i, j, x, y : longint; begin for i := 1 to n - 1 do for j := i + 1 to n do if board[i] < board[j] then begin x := board[i]; board[i] := board[j]; board[j] := x; end; for i := 1 to m - 1 do for j := i + 1 to m do if row[i] < row[j] then begin x := row[i]; row[i] := row[j]; row[j] := x; x := order[i]; order[i] := order[j]; order[j] := x; end; end; procedure init; var i, j, x : longint; begin readln(n, m); f := false; fillchar(put, sizeof(put), 0); fillchar(done, sizeof(done), false); for i := 1 to n do begin readln(board[i]); end; row[0] := 0; for i := 1 to m do begin readln(row[i]); order[i] := i; end; end; procedure print; var i, j, l : longint; begin for i := 1 to m do begin writeln(put[i, 0]); for j := 1 to put[i, 0] do write(put[i, j], ' '); writeln; end; halt; end; procedure make(k : longint); var i : longint; begin if f then exit; if (k = m + 1) then begin print; f := true; exit; end; for i := 1 to n do if (not done[i]) and (board[i] <= row[k]) then begin done[i] := true; dec(row[k], board[i]); inc(put[order[k], 0]); put[order[k], put[order[k], 0]] := board[i]; make(k + ord(row[k] = 0)); if f then exit; dec(put[order[k], 0]); inc(row[k], board[i]); done[i] := false; end; end; begin init; sort; make(1); end. Re: I had done my best but my program still be tle on test 14...need help... Posted by Jerry 16 Aug 2007 19:20 Add "Program URAL1115 in the front" Get a compiler Don't waste time~~~ |
|
|