Skip to content

Commit 3178b53

Browse files
Merge pull request #738 from gmlrude/main
[박희경] 120차 라이브 코테 제출
2 parents f6507fa + 7218b85 commit 3178b53

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import sys
2+
3+
input = sys.stdin.readline
4+
5+
n, s = map(int, input().split())
6+
arr = list(map(int, input().split()))
7+
8+
i, j = 0, 0
9+
prefix_sum = arr[0]
10+
res = float('inf')
11+
12+
while True:
13+
if j >= n:
14+
break
15+
if prefix_sum >= s:
16+
res = min(res, j-i+1)
17+
prefix_sum -= arr[i]
18+
i += 1
19+
else:
20+
j += 1
21+
if j < n:
22+
prefix_sum += arr[j]
23+
24+
if res != float('inf'):
25+
print(res)
26+
else:
27+
print(0)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import sys
2+
3+
input = sys.stdin.readline
4+
5+
n, m, k = map(int, input().split())
6+
board = []
7+
for _ in range(n):
8+
board.append(list(map(str, input().rstrip())))
9+
10+
cnt = []
11+
for a in range(n - k + 1):
12+
for b in range(m - k + 1):
13+
white = 0
14+
black = 0
15+
for i in range(a, a + k):
16+
for j in range(b, b + k):
17+
# 처음 색과 같아야 하는 부분
18+
if (i + j) % 2 == 0:
19+
if board[i][j] != 'W':
20+
white += 1
21+
else:
22+
black += 1
23+
# 처음 색과 달라야 하는 부분
24+
else:
25+
if board[i][j] != 'W':
26+
black += 1
27+
else:
28+
white += 1
29+
cnt.append(white)
30+
cnt.append(black)
31+
print(min(cnt))

0 commit comments

Comments
 (0)