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

14777번 - The County Fair 다국어

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

문제

Every year, Farmer John loves to attend the county fair. The fair has N booths (1 <= N <= 400), and each booth i is planning to give away a fabulous prize at a particular time P(i) (0 <= P(i) <= 1,000,000,000) during the day. Farmer John has heard about this and would like to collect as many fabulous prizes as possible to share with the cows. He would like to show up at a maximum possible number of booths at the exact times the prizes are going to be awarded.

Farmer John investigated and has determined the time T(i,j) (always in range 1..1,000,000) that it takes him to walk from booth i to booth j. The county fair's unusual layout means that perhaps FJ could travel from booth i to booth j by a faster route if he were to visit intermediate booths along the way. Being a poor map reader, Farmer John never considers taking such routes -- he will only walk from booth i to booth j in the event that he can actually collect a fabulous prize at booth j, and he never visits intermediate booths along the way. Furthermore, T(i,j) might not have the same value as T(j,i) owing to FJ's slow walking up hills.

Farmer John starts at booth #1 at time 0. Help him collect as many fabulous prizes as possible.

입력

  • Line 1: A single integer, N.
  • Lines 2..1+N: Line i+1 contains a single integer, P(i).
  • Lines 2+N..1+N+N^2: These N^2 lines each contain a single integer T(i,j) for each pair (i,j) of booths. The first N of these lines respectively contain T(1,1), T(1,2), ..., T(1,N). The next N lines contain T(2,1), T(2,2), ..., T(2,N), and so on. Each T(i,j) value is in the range 1...1,000,000 except for the diagonals T(1,1), T(2,2), ..., T(N,N), which have the value zero.

출력

  • Line 1: A single integer, containing the maximum number of prizes Farmer John can acquire.

제한

예제 입력 1

4
13
9
19
3
0
10
20
3
4
0
11
2
1
15
0
12
5
5
13
0

예제 출력 1

3

힌트

출처

Olympiad > USA Computing Olympiad > 2005-2006 Season > USACO US Open 2006 Contest > Gold 1번

Olympiad > USA Computing Olympiad > 2005-2006 Season > USACO US Open 2006 Contest > Silver 1번

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

출처

대학교 대회

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

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