[파이썬] 백준 - 7단계 2차원 배열
색종이 (2563)
N = int(input())
map_size = 101
length = 10
plane = []
for i in range(map_size):
temp = []
for k in range(map_size):
temp.append(0)
plane.append(temp)
for k in range(N):
x,y = map(int,input().split())
for i in range(length):
for j in range(length):
plane[x+i][y+j]=1
count = 0
for i in range(101):
count += sum(plane[i])
print(count)
세로읽기 (10798)
temp = []
for i in range(5):
s = str(input())
temp.append(list(f'{s:<15}'))
answer = ''
for w in range(15):
for h in range(5):
if temp[h][w] != ' ':
answer += temp[h][w]
print(answer)
f string을 이용해서 정렬 후 2차원 배열 만들고 풀기
최댓값 (2566)
array = []
max_values = []
for i in range(9):
temp = list(map(int,input().split()))
array.append(temp)
max_values.append(max(temp))
print(max(max_values))
print(max_values.index(max(max_values))+1,
array[max_values.index(max(max_values))].index(max(array[max_values.index(max(max_values))]))+1)
최댓값 중 하나의 위치 출력하는거라서 인덱스 접근해서 풀기. 하나 위치만 출력하는 거라 초기값만 잘 찾으면 된다.
모두 출력하는거면 갱신하면서 풀기
행렬 덧셈 (2738)
N,M = map(int,input().split())
A,B = [],[]
for h in range(N):
temp=list(map(int,input().split()))
A.append(temp)
for h in range(N):
temp=list(map(int,input().split()))
B.append(temp)
for h in range(N):
for w in range(M):
print(A[h][w]+B[h][w],end=' ')
print('')
'Algorithm > etc' 카테고리의 다른 글
[파이썬] 백준 - 14단계 집합과 맵 (0) | 2023.04.18 |
---|---|
[파이썬] 백준 - 13단계 정렬 (0) | 2023.04.17 |
[파이썬] 백준 - 10단계 기하: 직사각형과 삼각형 (0) | 2023.04.08 |
[파이썬] 백준 - 9단계 약수, 배수와 소수 (0) | 2023.04.08 |
[파이썬] 백준 - 8단계 입출력과 사칙연산 (0) | 2023.04.05 |
[파이썬] 프로그래머스 레벨2 (0) | 2023.04.02 |
[파이썬] 프로그래머스 레벨1 (0) | 2023.03.30 |
댓글