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

10294번 - Shops 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 256 MB30171254.545%

문제

In a country fair, the shopping area is divided into N x 5 cells with N columns and 5 rows. (1 <= N <= 50,000) Each cell is out for rent. You have survey the site and, for any cell, calculate the estimated profit if you rent that cell. Ideally, as you have unlimited money for renting, you would like to rent all the cells, but the fair organizer prevents any company to rent any two cells which are adjacent. (Two cells are adjacent if they are next to each other in the up, down, left and right direction.)

Your task is to write a program that calculate the maximum profit that you can get by renting cells that are all non-adjacent.

입력

The first line of the input denotes an integer T, (1 <= T <= 5) the number of test cases. Then T test cases follows in the format described next.

  • The first line of the test case contains an integer N (1 <= N <= 50,000)
  • The next 5 lines shows the profits on all the cells. That is, line 1+i contains N nonnegative integers representing the profits on all cells in row i. The profits will be at most 10,000.

출력

For each test case, output one integer which is the maximum total profit that you can get by renting cells which are non-adjacent.

제한

예제 입력 1

2
5
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
6
1 0 0 0 0 0
0 1 1 10 1 0
1 10 0 0 5 10
0 1 1 10 0 0
1 0 0 0 1 10

예제 출력 1

13
52

힌트

출처

ICPC > Regionals > Asia Pacific > Thailand > Thailand Central Group-A Programming Contest > Thailand Central Group-A Programming Contest 2014 D번

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

출처

대학교 대회

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

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