https://www.acmicpc.net/problem/2621
2621๋ฒ: ์นด๋๊ฒ์
๊ทผ์ฐ๋ ์ค๋ ์ฌ๋ฏธ์๋ ์นด๋ ๊ฒ์์ ๋ฐฐ์ฐ๊ณ ์๋ค. ์นด๋๋ ๋นจ๊ฐ์, ํ๋์, ๋ ธ๋์, ๋ น์์ ๋ค ๊ฐ์ง ์์ด ์๊ณ , ์๊น๋ณ๋ก 1๋ถํฐ 9๊น์ง ์ซ์๊ฐ ์ฐ์ฌ์ง ์นด๋๊ฐ 9์ฅ์ฉ ์๋ค. ์นด๋๋ ๋ชจ๋ 36(=4x9)์ฅ์ด๋ค.
www.acmicpc.net
ํ ์ด ๋ฌธ์ ์ ๋ง ์ด์ง๋ฌ์ ๋ค...
๊ทธ๋ฅ ๋จ์ ๊ตฌํ ๋ฌธ์ ์ธ๋ฐ ๋ฌธ์ ๊ฐ ์ ์ฝํ์...
์๋ฌดํผ, ๊ทธ๋ฅ ํ๋ผ๋๋๋ก ํ๋ค.
์ฐ์ ์ด ๋ฌธ์ ์์ ์ฃผ์ด์ง๋ ์ซ์์ ์์๋ ์ค์ํ์ง ์์ผ๋ฏ๋ก, 5๊ฐ์ ์ซ์๊ฐ ์ฐ์์ธ์ง ํ์ธํ๊ธฐ ์ํด์ ์ซ์๋ค์ ์ ๋ ฌํด์ฃผ์๋ค.
๋, ์ฒ์์๋ Counter๋ฅผ ์ธ๊น ํ์ง๋ง ๊ดํ ๋ ๋ณต์กํด์ง๋ ๊ฒ ๊ฐ์์, ๊ทธ๋ฅ 9์นธ์ง๋ฆฌ ๋ฆฌ์คํธ๋ฅผ ๋ง๋ค์ด์ 1~9๊น์ง ์ซ์๊ฐ ๋ช ๋ฒ ๋์๋์ง ๊ธฐ๋กํด ๋์๋ค.
๊ท์น๋ค์ด ์๋ก ๊ฒน์น๋ ๋ถ๋ถ๋ค์ด ์์ด์, ๊ท์น ์์๋ฅผ ์กฐ์ ํ๋ฉด ์ข ๋ ํธํ๊ฒ ํ ์ ์์ ๊ฒ ๊ฐ์๋๋ฐ,
๊ดํ ์ง ํ๋ค๊ฐ ๋ชจ๋ฅด๊ณ ํ ๊ฐ์ฉ ๋นผ๋จน๊ณ ๋์ด๊ฐ๊น๋ด
๊ทธ๋ฅ ์์ ํ๊ฒ 1๋ฒ๋ถํฐ ์ญ ๊ตฌํํ๋ค.
๋ด ์ฝ๋๊ฐ ์ข์ ์ฝ๋ ๊ฐ์ง๋ ์์์ ์ฌ๋ฌ ์ฌ๋๋ค ์ฝ๋๋ฅผ ๊ตฌ๊ฒฝํด๋ดค๋๋ฐ,
๋ค๋ค ๊ทธ๋ฅ ํ๋ผ๋๋๋ก ์ฐฉ์คํ๊ฒ ๊ตฌํํ์ ๊ฒ ๊ฐ์๋ค!!
python
color = []
number = []
ncnt = [0,0,0,0,0,0,0,0,0]
for _ in range(5):
c, n = input().split()
color.append(c)
number.append(int(n))
ncnt[int(n)-1] += 1
number.sort()
score = 0
# 1
flag = True # 5๊ฐ ์ซ์๊ฐ ์ฐ์ํ์ง
for i in range(4):
if number[i] + 1 != number[i+1]:
flag = False
break
if flag and len(set(color)) == 1:
score = max(number) + 900
# 2
if 4 in ncnt:
idx = 0
for i in range(9):
if ncnt[i] == 4:
idx = i + 1
break
score = max(score, idx + 800)
# 3
two, three = 0, 0
for i in range(9):
if ncnt[i] == 2:
two = i + 1
if ncnt[i] == 3:
three = i + 1
if two > 0 and three > 0:
score = max(score, three*10 + two + 700)
# 4
if len(set(color)) == 1:
score = max(score, max(number) + 600)
# 5
if flag:
score = max(score, max(number) + 500)
# 6
if three > 0:
score = max(score, three + 400)
# 8
if two > 0:
score = max(score, two + 200)
# 7
t1, t2 = 0, 0
for i in range(9):
if ncnt[i] == 2:
if t1 == 0:
t1 = i + 1
else:
t2 = i + 1
if t1 > 0 and t2 > 0:
score = max(score, t2 * 10 + t1 + 300)
# 9
if score == 0:
score = max(number) + 100
print(score)
'์๊ณ ๋ฆฌ์ฆ ๋ฌธ์ ํ์ด > ๊ตฌํ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[softeer] GBC (0) | 2023.05.18 |
---|---|
[ํ๋ก๊ทธ๋๋จธ์ค]ํธ๋ ํ์ดํธ ๋ํ (0) | 2023.05.14 |
[๋ฐฑ์ค]1913๋ฒ: ๋ฌํฝ์ด (0) | 2023.05.10 |
[๋ฐฑ์ค]10972๋ฒ: ๋ค์ ์์ด / 10973๋ฒ: ์ด์ ์์ด (0) | 2023.05.09 |
[๋ฐฑ์ค]17413๋ฒ: ๋จ์ด ๋ค์ง๊ธฐ 2 (0) | 2023.05.09 |