Machine allocation Hnoi
Time limit:10000ms memory limit:65536k
Total submit:166 accepted:105
Case Time Limit : 1000MS
Description
Head Office has an efficient production equipment m platform, ready to be assigned to the subordinates of the N companies. If each branch company obtains these equipment, may provide the country certain profit. Q: How to allocate this m device to make the country the most profitable. Find the maximum profit value. where M "=15,n〈=10." Allocation principle: Each company has the right to obtain any number of equipment, but the total number of units must not exceed the total number of units m. The first row of
Input
holds two numbers, the first number is the number of units m, and the second number is the number of branches N. Next is a matrix of m*n, which shows that the first company allocates the profit of the J machine.
Output
Maximum profit
Sample Input
-
8, 1, 28, 107 136, 104, 176 127 133
184, 223 179 198 134 113 247 225 205
3 136 273 217 249 279 117 312 296 205
286 207 315 306 291 224 209 346 370 272
292 317 332 372 227 223 375 370 295
361 327 363 373 453 277 286 410 463 425
393 413 369 387 542 302 289 419 473 393
443 455 407 561 358 33 6 477 491 445
469 521 554 478 589 to 364 572 537 591 475 534 570 520 603 530 405 574 602 593
496 542 547 654 587 431 587 664 637
577 632 657 645 700 635 527 620 680 680
656 643 670 670 730 715 573 676 721 707
713 71 9 685 685 757 770 642 744 728 745
Sample Output
1167
Var a,f:array[0..15,0..15]of longint;
i,j,n,m,max,k:longint;
Begin
read (m,n);
for i:=1 to M does
for j:=1 to n do
read (a[j,i]);
for i:=1 to N does
for j:=0-M do
begin
max:=0;
for k:=0 to J does
If F[i-1,k]+a[i,j-k]>max then
 MAX:=F[I-1 , K]+a[i,j-k];
f[i,j]:=max;
END;
writeln (f[n,m]);
End.