CF362E.Petya and Pipes

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 nn water tanks numbered from 11 to nn . 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 11 ). The water must go through some pipe path and get to the sewer tank with cleaning system (its number is nn ).

Petya wants to increase the width of some subset of pipes by at most kk 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 nn and kk ( 2<=n<=502<=n<=50 , 0<=k<=10000<=k<=1000 ). Then follow nn lines, each line contains nn integers separated by single spaces. The i+1i+1 -th row and jj -th column contain number cijc_{ij} — the width of the pipe that goes from tank ii to tank jj ( 0<=cij<=106,cii=00<=c_{ij}<=10^{6},c_{ii}=0 ). If cij=0c_{ij}=0 , then there is no pipe from tank ii to tank jj .

输出格式

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 11 st to the 22 nd water tank by 77 units.

In the second test Petya can increase width of the pipe that goes from the 11 st to the 22 nd water tank by 44 units, from the 22 nd to the 33 rd water tank by 33 units, from the 33 rd to the 44 th water tank by 22 units and from the 44 th to 55 th water tank by 11 unit.

首页