Skip to content

Commit 4f30bc9

Browse files
authored
Merge pull request #22 from Mingguriguri/minjeong
Minjeong / 4์›” 3์ฃผ์ฐจ / 4๋ฌธ์ œ
2 parents fbe8d06 + 1c5d22a commit 4f30bc9

4 files changed

+59
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
n, k = map(int, input().split()) # n: ๋™์ „์˜ ์ข…๋ฅ˜ k: ๊ฐ€์น˜์˜ ํ•ฉ
2+
coin_type = [] # ๋™์ „์˜ ์ข…๋ฅ˜๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๋ฆฌ์ŠคํŠธ
3+
count = 0 # ๋™์ „ ๊ฐœ์ˆ˜๋ฅผ ์ €์žฅํ•  ๋ณ€์ˆ˜
4+
5+
for _ in range(n): # ๋™์ „ ์ข…๋ฅ˜ ์ž…๋ ฅํ•˜์—ฌ ๋ฆฌ์ŠคํŠธ์— ์ €์žฅ
6+
coin = int(input())
7+
coin_type.append(coin)
8+
9+
coin_type.sort(reverse=True) # ๋™์ „ ์ข…๋ฅ˜๋ฅผ ๋™์ „์˜ ๊ฐ’์ด ํฐ ์ˆœ์„œ๋Œ€๋กœ (์—ญ์ˆœ์œผ๋กœ) ์ •๋ ฌ
10+
11+
for i in range(n):
12+
if (k // coin_type[i] ): # ๋ชซ์ด ์กด์žฌํ•œ๋‹ค๋ฉด ์•„๋ž˜ ์กฐ๊ฑด๋ฌธ ์‹คํ–‰
13+
mok = k // coin_type[i] # ๋ชซ์„ ๊ตฌํ•˜์—ฌ ์ €์žฅ
14+
count += mok # ๋ชซ๋งŒํผ ๋™์ „ ๊ฐœ์ˆ˜์— ๋”ํ•˜๊ธฐ
15+
k -= coin_type[i] * mok # ์›๋ž˜ ๊ฐ’์ธ k์—๋Š” ๊ทธ๋งŒํผ ๋นผ์ฃผ๊ธฐ
16+
print(count) # ์ •๋‹ต ์ถœ๋ ฅ
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
tc = int(input()) # ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค์˜ ์ˆ˜ ์ž…๋ ฅ
2+
for _ in range(tc):
3+
n = int(input()) # ์˜์ƒ์˜ ์ˆ˜ ์ž…๋ ฅ
4+
clothes = {} # ์˜์ƒ ์ข…๋ฅ˜๋ณ„๋กœ ์˜์ƒ์„ ์ €์žฅํ•  ์‚ฌ์ „
5+
for _ in range(n):
6+
cloth_name, cloth_type = map(str, input().split())
7+
if cloth_type in clothes:
8+
clothes[cloth_type].append(cloth_name)
9+
else:
10+
clothes[cloth_type] = [cloth_name]
11+
12+
# ๊ฐ ์˜์ƒ ์ข…๋ฅ˜๋ณ„๋กœ ์„ ํƒํ•  ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ•์˜ ์ˆ˜ ๊ณ„์‚ฐ (์•„๋ฌด๊ฒƒ๋„ ์„ ํƒํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ ํฌํ•จ)
13+
combinations = 1
14+
for key in clothes:
15+
combinations *= (len(clothes[key]) + 1)
16+
17+
# ์•Œ๋ชธ ์ƒํƒœ ์ œ์™ธ (๋ชจ๋“  ์˜์ƒ ์ข…๋ฅ˜์—์„œ ์•„๋ฌด๊ฒƒ๋„ ์„ ํƒํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ)
18+
combinations -= 1
19+
20+
print(combinations) # ๊ฐ€๋Šฅํ•œ ์กฐํ•ฉ์˜ ์ˆ˜ ์ถœ๋ ฅ
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
TC = int(input())
2+
dp = [[0, 0]] * 100
3+
dp[0] = [1, 0]
4+
dp[1] = [0, 1]
5+
6+
for i in range(2, 100): # ๋ฏธ๋ฆฌ DP์— ์ €์žฅํ•ด๋‘๊ธฐ (0.25์ดˆ์˜ ์†๋„๋ฅผ ์œ„ํ•จ)
7+
dp[i] = [dp[i-1][0]+dp[i-2][0], dp[i-1][1]+dp[i-2][1]]
8+
9+
for _ in range(TC): # ํ…Œ์ŠคํŠธ์ผ€์ด์Šค ์ˆ˜๋งŒํผ ๋ฐ˜๋ณต
10+
n = int(input()) # ํ…Œ์ŠคํŠธ์ผ€์ด์Šค n
11+
print(' '.join(map(str, dp[n]))) # dp์— ์ €์žฅ๋œ ๊ฐ’ ์ถœ๋ ฅ
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
n, m = map(int, input().split()) # n: ์ €์žฅ๋œ ์‚ฌ์ดํŠธ ์ˆ˜, m: ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ฐพ์œผ๋ ค๋Š” ์‚ฌ์ดํŠธ์˜ ์ˆ˜
2+
password = {} # ๋น„๋ฐ€๋ฒˆํ˜ธ ๋”•์…”๋„ˆ๋ฆฌ ์„ ์–ธ
3+
4+
# ์ €์žฅ๋œ ์‚ฌ์ดํŠธ์˜ ์ˆ˜
5+
for _ in range(n):
6+
site, pw = map(str, input().split())
7+
password[site] = pw # ์‚ฌ์ดํŠธ์— ๋Œ€ํ•œ ๋น„๋ฐ€๋ฒˆํ˜ธ ์ €์žฅ
8+
9+
# ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ฐพ์œผ๋ ค๋Š” ์‚ฌ์ดํŠธ
10+
for _ in range(m):
11+
search = input()
12+
print(password[search])

0 commit comments

Comments
ย (0)