Skip to content

Commit 3ab4af4

Browse files
Merge pull request #527 from gmlrude/main
[박희경] 65차 라이브 코테 제출
2 parents 33d4921 + 755e376 commit 3ab4af4

File tree

3 files changed

+105
-0
lines changed

3 files changed

+105
-0
lines changed

live6/test65/문제1/박희경.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import sys
2+
3+
input = sys.stdin.readline
4+
5+
n = int(input())
6+
7+
board = []
8+
for _ in range(n):
9+
board.append(list(map(str, input().rstrip())))
10+
11+
12+
def counting():
13+
max_cnt = 1
14+
for i in range(n):
15+
cnt_row = cnt_col = 1
16+
for j in range(n - 1):
17+
# 가로
18+
if board[i][j] == board[i][j + 1]: # 같은 색이면
19+
cnt_row += 1
20+
else:
21+
cnt_row = 1 # 다른 색이면 카운트 다시 시작
22+
max_cnt = max(max_cnt, cnt_row)
23+
24+
for j in range(n - 1):
25+
# 세로
26+
if board[j][i] == board[j + 1][i]:
27+
cnt_col += 1
28+
else:
29+
cnt_col = 1
30+
max_cnt = max(max_cnt, cnt_col)
31+
return max_cnt
32+
33+
res = 1
34+
for i in range(n):
35+
for j in range(n - 1):
36+
if n > j + 1 and board[i][j] != board[i][j + 1]:
37+
# 아래와 교환
38+
board[i][j], board[i][j + 1] = board[i][j + 1], board[i][j]
39+
res = max(res, counting())
40+
# 복구
41+
board[i][j], board[i][j + 1] = board[i][j + 1], board[i][j]
42+
if n > i + 1 and board[i][j] != board[i + 1][j]:
43+
# 왼쪽과 교환
44+
board[i][j], board[i + 1][j] = board[i + 1][j], board[i][j]
45+
res = max(res, counting())
46+
board[i][j], board[i + 1][j] = board[i + 1][j], board[i][j]
47+
48+
print(res)

live6/test65/문제2/박희경.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import sys
2+
3+
input = sys.stdin.readline
4+
5+
n = int(input())
6+
schedule = [[0, 0]]
7+
for _ in range(n):
8+
schedule.append(list(map(int, input().split())))
9+
10+
profit = 0
11+
12+
13+
def find_max_profit(day, current_profit):
14+
global profit
15+
16+
# n일 넘어가면 최대이익 갱신
17+
if day > n:
18+
profit = max(profit, current_profit)
19+
return
20+
21+
# 상담하지 않는 경우
22+
find_max_profit(day + 1, current_profit)
23+
24+
if day + schedule[day][0] - 1 <= n:
25+
find_max_profit(day + schedule[day][0], current_profit + schedule[day][1])
26+
27+
28+
find_max_profit(1, 0)
29+
print(profit)
30+
31+
"""
32+
7
33+
3 10
34+
5 20
35+
1 10
36+
1 20
37+
2 15
38+
4 40
39+
2 200
40+
"""

live6/test65/문제3/박희경.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
def solution(s):
2+
s = list(s.rstrip())
3+
stack = []
4+
5+
for alpa in s:
6+
if stack:
7+
if stack[-1] == alpa:
8+
stack.pop()
9+
else:
10+
stack.append(alpa)
11+
else:
12+
stack.append(alpa)
13+
14+
if stack:
15+
return 0
16+
else:
17+
return 1

0 commit comments

Comments
 (0)