일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 12865번
- 9095번
- SW Expert Academy
- 19238번
- 프로그래머스
- 경주로 건설
- 거울 설치
- 1038번
- 수식 최대화
- 14499번
- SW ExpertAcademy
- 16234번
- 감소하는 수
- 베스트엘범
- 17144번
- HTML 기초
- 어른 상어
- 1789번
- 15686번
- 스타트 택시
- 파이썬
- python
- QueryDSL 기초
- 2020 카카오 인턴십
- 12869번
- 백준 알고리즘
- 미세먼지 안녕!
- 키패드 누르기
- 빛의 경로 사이클
- 보석 쇼핑
Archives
- Today
- Total
보물창고 블로그
SW Expert Academy 2115. [모의 SW 역량테스트] 벌꿀채취 본문
728x90
문제 링크: https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5V4A46AdIDFAWu
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
해결한 코드는 아래와 같다.
def solution(map2, n, m, c):
answer = 0
for i in range(n):
for j in range(n):
if j + m - 1 < n:
sub1 = []
for p in range(m):
sub1.append(map2[i][j + p])
for i2 in range(i, n):
for j2 in range(n):
if i2 == i and j2 <= j + m - 1:
continue
elif j2 + m - 1 < n:
sub2 = []
for p in range(m):
sub2.append(map2[i2][j2 + p])
sub = 0
c1 = 0
c2 = 0
c3 = 0
c4 = 0
r1 = 0
r2 = 0
r3 = 0
r4 = 0
sub1.sort(reverse=True)
sub2.sort(reverse=True)
for p1 in range(m):
if c1 + sub1[p1] <= c:
c1 += sub1[p1]
r1 += pow(sub1[p1], 2)
if c2 + sub1[m - 1 - p1] <= c:
c2 += sub1[m - 1 - p1]
r2 += pow(sub1[m - 1 - p1], 2)
if c3 + sub2[p1] <= c:
c3 += sub2[p1]
r3 += pow(sub2[p1], 2)
if c4 + sub2[m - 1 - p1] <= c:
c4 += sub2[m - 1 - p1]
r4 += pow(sub2[m - 1 - p1], 2)
sub += max(r1, r2) + max(r3, r4)
if answer < sub:
answer = sub
else:
continue
else:
continue
return answer
t = int(input())
for test in range(1, t + 1):
n, m, c = map(int, input().split())
map1 = [list(map(int, input().split())) for _ in range(n)]
ans = solution(map1, n, m, c)
print('#{} {}'.format(test, ans))
'알고리즘 풀이 > SW Expert Academy' 카테고리의 다른 글
SW Expert Academy 5648. [모의 SW 역량테스트] 원자 소멸 시뮬레이션 (0) | 2020.03.10 |
---|---|
SW Expert Academy 5650. [모의 SW 역량테스트] 핀볼 게임 (0) | 2020.03.10 |
SW Expert Academy 2112. [모의 SW 역량테스트] 보호 필름 (0) | 2020.03.04 |
SW Expert Academy 1953. [모의 SW 역량테스트] 탈주범 검거 (0) | 2020.03.04 |
SW Expert Academy 1952. [모의 SW 역량테스트] 수영장 (0) | 2020.03.04 |
Comments