λ¬Έμ
λ°±μ€ μ¨λΌμΈ μ μ§ - 14754λ²
νμ΄ κ³Όμ
νΌμλ°μ€λ€μ΄ μ£Όμ΄μ§ λ μκ³Ό μμμ λ΄€μ λ μ΅λ λμ΄μ λ³νκ° μλ νμμ μμ¨ μ μλ νΌμλ°μ€μ κ°μλ₯Ό ꡬνλ λ¬Έμ μ λλ€.
νκ³Ό μ΄μ κΈ°μ€μΌλ‘ νμνμ λ κ°μ₯ λμ μμΉμ μλ νΌμλ€μ λ¨κ²¨λκ³ λλ¨Έμ§λ μμ λ©΄ λ©λλ€.
λ°λΌμ O(N^2)
μ μκ° λ³΅μ‘λλ‘ μνλ κ°μλ₯Ό ꡬν μ μμ΅λλ€.
μ½λ
import sys
N, M = list(map(int, sys.stdin.readline().split()))
board = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def remove_pizza():
check = [[0] * M for _ in range(N)]
for x in range(N):
max_idx = 0
for y in range(M):
if board[x][max_idx] < board[x][y]:
max_idx = y
check[x][max_idx] = 1
for y in range(M):
max_idx = 0
for x in range(N):
if board[max_idx][y] < board[x][y]:
max_idx = x
check[max_idx][y] = 1
return check
def solution():
answer = 0
check = remove_pizza()
for x in range(N):
for y in range(M):
if not check[x][y]:
answer += board[x][y]
return answer
print(solution())
λ°μν
'π algorithm > boj' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
BOJ 18243 - Small World Network (0) | 2021.03.18 |
---|---|
BOJ 18238 - ZOAC2 (0) | 2021.03.18 |
BOJ 15723 - nλ¨ λ Όλ² (0) | 2021.03.18 |
BOJ 14496 - κ·Έλ, κ·Έλ¨Έκ° λμ΄ (0) | 2021.03.16 |
BOJ 9311 - Robot in a Maze (0) | 2021.03.14 |
π¬ λκΈ