#P2066. 机器分配
机器分配
Description
The head office has high-efficiency machines to distribute to subsidiary companies. If a company receives a certain number of machines, it can generate a corresponding profit for the country. How should these machines be allocated to maximize the total profit? Find the maximum profit. Constraints: , . Allocation rule: each company may receive any number of machines, but the total number cannot exceed .
If multiple allocations yield the same maximum profit, break ties by making earlier-indexed companies receive as few machines as possible, that is, minimize ; if still tied, minimize ; and so on.
Input Format
The first line contains two numbers: the number of companies and the number of machines .
Then follows an matrix. The entry at row and column gives the profit when company is assigned machines.
Output Format
The first line contains the maximum profit.
Then output lines. In the -th line, output the number of machines assigned to company .
3 3
30 40 50
20 30 50
20 25 30
70
1 1
2 1
3 1
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号