Skip to content

Commit bddc5e4

Browse files
committed
[BOJ] #1233. 주사위 / 브론즈2 / 10분 / 성공
1 parent 75b0acd commit bddc5e4

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import sys
2+
input = sys.stdin.readline
3+
4+
S1, S2, S3 = map(int, input().split())
5+
6+
# 가능한 합의 빈도를 저장할 딕셔너리
7+
sum_counts = {}
8+
9+
for i in range(1, S1+1):
10+
for j in range(1, S2+1):
11+
for k in range(1, S3+1):
12+
temp_sum = i + j + k
13+
if temp_sum in sum_counts:
14+
sum_counts[temp_sum] += 1
15+
else:
16+
sum_counts[temp_sum] = 1
17+
18+
# 가장 높은 빈도와 그 합을 찾는다.
19+
max_freq = max(sum_counts.values())
20+
# 답이 여러개라면 가장 합이 적은 것을 출력한다.
21+
answer = []
22+
for key, value in sum_counts.items():
23+
if value == max_freq:
24+
answer.append(key)
25+
print(min(answer))
26+
27+
'''
28+
S1, S2, S3 = map(int, input().split())
29+
arr = [0 for i in range(S1+S2+S3+1)]
30+
for i in range(S1):
31+
for j in range(S2):
32+
for k in range(S3):
33+
arr[i+j+k+3]+=1
34+
max = max(arr)
35+
for i in range(len(arr)):
36+
if arr[i] == max:
37+
print(i)
38+
break
39+
'''

0 commit comments

Comments
 (0)