#t384. 机器分配(assign)
机器分配(assign)
Allocating Machines to Companies
Background
Special for beginners, ^_^
Problem Description
The head office owns highly efficient machines and plans to distribute them among its branch companies. If a branch company receives these machines, it can generate a certain profit for the country. Question: how to allocate the machines so that the profit for the country is maximized? Find the maximum profit value. Here , . Allocation rule: each company may receive any number of machines, but the total number allocated cannot exceed . If there are multiple optimal solutions, the earlier companies should receive as few machines as possible.
Input Format
The first line contains two numbers: the first is the number of branch companies , and the second is the number of machines .
This is followed by an matrix; the value at position is the profit obtained when the -th company is allocated machines.
Output Format
The first line is an integer: the maximum profit.
This is followed by lines, each with two integers and , meaning that company is allocated machines.
Sample Input 1
2 15
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 2
Sample Output 1
2
1 0
2 15
Constraints
1s, 1024KiB for each test case.