A9207 | Petya and Pipes
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
A little boy Petya dreams of growing up and becoming the Head Berland Plumber. He is thinking of the problems he will have to solve in the future. Unfortunately, Petya is too inexperienced, so you are about to solve one of such problems for Petya, the one he's the most interested in.
The Berland capital has $n$ water tanks numbered from $1$ to $n$ . These tanks are connected by unidirectional pipes in some manner. Any pair of water tanks is connected by at most one pipe in each direction. Each pipe has a strictly positive integer width. Width determines the number of liters of water per a unit of time this pipe can transport. The water goes to the city from the main water tank (its number is $1$ ). The water must go through some pipe path and get to the sewer tank with cleaning system (its number is $n$ ).
Petya wants to increase the width of some subset of pipes by at most $k$ units in total so that the width of each pipe remains integer. Help him determine the maximum amount of water that can be transmitted per a unit of time from the main tank to the sewer tank after such operation is completed.
The Berland capital has $n$ water tanks numbered from $1$ to $n$ . These tanks are connected by unidirectional pipes in some manner. Any pair of water tanks is connected by at most one pipe in each direction. Each pipe has a strictly positive integer width. Width determines the number of liters of water per a unit of time this pipe can transport. The water goes to the city from the main water tank (its number is $1$ ). The water must go through some pipe path and get to the sewer tank with cleaning system (its number is $n$ ).
Petya wants to increase the width of some subset of pipes by at most $k$ units in total so that the width of each pipe remains integer. Help him determine the maximum amount of water that can be transmitted per a unit of time from the main tank to the sewer tank after such operation is completed.
输入格式
The first line contains two space-separated integers $n$ and $k$ ( $2<=n<=50$ , $0<=k<=1000$ ). Then follow $n$ lines, each line contains $n$ integers separated by single spaces. The $i+1$ -th row and $j$ -th column contain number $c_{ij}$ — the width of the pipe that goes from tank $i$ to tank $j$ ( $0<=c_{ij}<=10^{6},c_{ii}=0$ ). If $c_{ij}=0$ , then there is no pipe from tank $i$ to tank $j$ .
输出格式
Print a single integer — the maximum amount of water that can be transmitted from the main tank to the sewer tank per a unit of time.
输入输出样例
输入 #1
5 7 0 1 0 2 0 0 0 4 10 0 0 0 0 0 5 0 0 0 0 10 0 0 0 0 0
输出 #1
10
输入 #2
5 10 0 1 0 0 0 0 0 2 0 0 0 0 0 3 0 0 0 0 0 4 100 0 0 0 0
输出 #2
5
In the first test Petya can increase width of the pipe that goes from the $1$ st to the $2$ nd water tank by $7$ units.
In the second test Petya can increase width of the pipe that goes from the $1$ st to the $2$ nd water tank by $4$ units, from the $2$ nd to the $3$ rd water tank by $3$ units, from the $3$ rd to the $4$ th water tank by $2$ units and from the $4$ th to $5$ th water tank by $1$ unit.
In the second test Petya can increase width of the pipe that goes from the $1$ st to the $2$ nd water tank by $4$ units, from the $2$ nd to the $3$ rd water tank by $3$ units, from the $3$ rd to the $4$ th water tank by $2$ units and from the $4$ th to $5$ th water tank by $1$ unit.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted