ν°μ€ν 리 λ·°
728x90
λ°μν
λ¬Έμ
λ¬Έμ νμ΄
μμ κ·Έλ¦Όκ³Ό κ°μ΄ νλ ¬μ λͺ¨λ ν©μ ꡬνκ³ , μ΅λ κ°μ λ°ννλ λ¬Έμ μ΄λ€. μ΄λ νμ΄μ¬μ κ²½μ° κ°λ¨νκ² ν΄κ²°ν μ μλ€.
trans_array = list(map(list, zip(*array)))
μμ νλ ¬μ `numpy`λ₯Ό μ¬μ©νμ§ μκ³ μ μΉνκΈ° μν΄μλ μμ κ°μ΄ μ μΉν μ μλ€. λ°λΌμ μ μΉμν€κ² λλ©΄ νλ ¬μ ν©μ λ³΄λ€ νΈνκ² κ΅¬ν μ μλ€.
# β λκ°μ μ ν©
left_right = sum([array[i][i] for i in range(100)])
# β λκ°μ μ ν©
right_left = sum([array[i][99 - i] for i in range(100)])
λκ°μ μ ν©μ μ’μΈ‘μμ μ°μΈ‘μΌλ‘ λ΄λ €μ€λ κ²½μ° [0][0], [1][1]κ³Ό κ°μ΄ μ κ·Όνλ©΄ λλ€. μ΄μ λ¬λ¦¬ μ°μΈ‘μμ μ’μΈ‘μΌλ‘ λ΄λ €μ€λ κ²½μ°μ λκ°μ μ [0][99], [1][98]κ³Ό κ°μ΄ μ κ·Όνλ©΄ λλ€.
μ½λ
for test_case in range(1, 11):
answer = 0
t = int(input())
array = [list(map(int, input().split())) for _ in range(100)]
# νλ ¬ μ μΉ
trans_array = list(map(list, zip(*array)))
# β λκ°μ μ ν©
left_right = sum([array[i][i] for i in range(100)])
# β λκ°μ μ ν©
right_left = sum([array[i][99 - i] for i in range(100)])
for i in range(100):
answer = max(answer, max(sum(array[i]), sum(trans_array[i])))
answer = max(answer, max(left_right, right_left))
print('#' + str(test_case), answer)
728x90
λ°μν
'π¨βπ» μ½λ©ν μ€νΈ > SWEA' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
SWEA: 1221 GNS (0) | 2020.10.07 |
---|---|
SWEA: 1220 Magnetic (0) | 2020.10.07 |
SWEA: 1215 νλ¬Έ1 (0) | 2020.10.07 |
SWEA: 1208 Flatten (0) | 2020.10.07 |
SWEA: 1206 View (0) | 2020.10.07 |
λκΈ
κΈ λ³΄κ΄ν¨
μ΅κ·Όμ μ¬λΌμ¨ κΈ
μ΅κ·Όμ λ¬λ¦° λκΈ