Logo
(追記) (追記ここまで)

16617번 - Far, Far Away 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB29181672.727%

문제

As you know, the purpose of a journey is not to reach the destination but to make the trip. You want to make a trip with as many legs as possible. However, each leg of the trip costs some money and your budget is limited. Find the longest path!

입력

The first line contains two integers n (1 ≤ n ≤ 100), which is the number of locations, and m (1 ≤ m ≤ 109), which is the amount of available money.

The next n lines describe the legs. Each of these lines contains n integers, where the jth integer of the ith line cij is the cost of a leg from location i to location j (1 ≤ cij ≤ 109 for each 1 ≤ i, j ≤ n). Your trip must start at location 1 and may end at any location.

출력

Display the maximum number of legs a trip from location 1 can have such that the sum of the costs of its legs is at most m. A trip may repeatedly visit the same location (including start and destination) and repeatedly use the same leg (paying its cost multiple times).

제한

예제 입력 1

2 7
3 2
1 3

예제 출력 1

4

예제 입력 2

3 9
2 5 4
1 2 1
1 1 2

예제 출력 2

6

예제 입력 3

2 1
2 2
1 1

예제 출력 3

0

예제 입력 4

2 3
1 10
10 10

예제 출력 4

3

힌트

출처

ICPC > Regionals > South Pacific > South Pacific Region > 2018 ACM South Pacific Programming Contest F번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /