Skip to content

Commit e2af90a

Browse files
Merge pull request #661 from gmlrude/main
[박희경] 99차 라이브 코테 제출
2 parents 6e8ebed + d7348e8 commit e2af90a

3 files changed

Lines changed: 84 additions & 0 deletions

File tree

live9/test99/문제1/박희경.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import sys
2+
from itertools import *
3+
4+
input = sys.stdin.readline
5+
6+
n = int(input())
7+
a = list(map(int, input().split()))
8+
9+
operator_cnt = list(map(int, input().split()))
10+
11+
max_value = float('-inf')
12+
min_value = float('inf')
13+
14+
15+
def bf(value, idx):
16+
global max_value, min_value
17+
if idx == n:
18+
max_value = max(max_value, value)
19+
min_value = min(min_value, value)
20+
return
21+
if operator_cnt[0] > 0:
22+
operator_cnt[0] -= 1
23+
bf(value + a[idx], idx + 1)
24+
operator_cnt[0] += 1 # 놓친 부분
25+
26+
if operator_cnt[1] > 0:
27+
operator_cnt[1] -= 1
28+
bf(value - a[idx], idx + 1)
29+
operator_cnt[1] += 1
30+
31+
if operator_cnt[2] > 0:
32+
operator_cnt[2] -= 1
33+
bf(value * a[idx], idx + 1)
34+
operator_cnt[2] += 1
35+
36+
if operator_cnt[3] > 0:
37+
operator_cnt[3] -= 1
38+
bf(int(value / a[idx]), idx + 1) # 놓친 부분
39+
operator_cnt[3] += 1
40+
41+
bf(a[0], 1)
42+
print(max_value)
43+
print(min_value)

live9/test99/문제2/박희경.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import sys
2+
from itertools import *
3+
4+
input = sys.stdin.readline
5+
6+
n, m = map(int, input().split())
7+
arr = sorted(list(map(int, input().split())))
8+
9+
for perm in permutations(arr, m):
10+
print(*perm)

live9/test99/문제3/박희경.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from collections import *
2+
3+
def is_correct(arr):
4+
stack = []
5+
for a in arr:
6+
if a in '([{':
7+
stack.append(a)
8+
elif a == ')':
9+
if not stack or stack[-1] != '(':
10+
return False
11+
stack.pop()
12+
elif a == ']':
13+
if not stack or stack[-1] != '[':
14+
return False
15+
stack.pop()
16+
elif a == '}':
17+
if not stack or stack[-1] != '{':
18+
return False
19+
stack.pop()
20+
21+
return not stack
22+
23+
def solution(s):
24+
answer = 0
25+
queue = deque(s)
26+
27+
for _ in range(len(queue)):
28+
if is_correct(queue):
29+
answer += 1
30+
queue.rotate(-1)
31+
return answer

0 commit comments

Comments
 (0)