Skip to content

Commit 1302ca6

Browse files
authored
Merge pull request #115 from learntosurf/main
Learntosurf / 12μ›” 4μ£Όμ°¨ / 2문제
2 parents 3dea476 + aee3a54 commit 1302ca6

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'''
2+
BOJ #1931. νšŒμ˜μ‹€ λ°°μ • (κ³¨λ“œ5)
3+
https://www.acmicpc.net/problem/1931
4+
μœ ν˜•: Greedy
5+
좜처: https://v3.leedo.me/devs/49
6+
'''
7+
8+
n = int(input())
9+
10+
meetings = []
11+
12+
for _ in range(n):
13+
start, end = map(int, input().split(" "))
14+
meetings.append((start, end))
15+
# μ’…λ£Œ μ‹œκ°„μ„ μ˜€λ¦„μ°¨μˆœ μ •λ ¬ν•˜κ³ , μ‹œμž‘ μ‹œκ°„μ„ μ˜€λ¦„μ°¨μˆœ μ •λ ¬ν•©λ‹ˆλ‹€
16+
meetings.sort(key=lambda x: (x[1], x[0]))
17+
18+
time = 0
19+
answer = 0
20+
for meeting in meetings:
21+
if time <= meeting[0]:
22+
time = meeting[1]
23+
answer += 1
24+
25+
print(answer)

β€Ž_WeeklyChallenges/W05-[Greedy]/README.mdβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212

1313
### πŸ’» 과제
1414
- [λ°±μ€€ #1931. νšŒμ˜μ‹€ λ°°μ •](https://www.acmicpc.net/problem/1931): 그리디, μ •λ ¬ / κ³¨λ“œ5
15-
- μ •λ‹΅ μ½”λ“œ: [Assignment_BOJ_1931_νšŒμ˜μ‹€λ°°μ •.py](./Assignment_BOJ_1931_νšŒμ˜μ‹€λ°°μ •.py)
15+
- μ •λ‹΅ μ½”λ“œ: [Assignment_BOJ_1931_νšŒμ˜μ‹€λ°°μ •.py](./Assignment_BOJ_1931_νšŒμ˜μ‹€λ°°μ •.py)

β€Žlearntosurf/Greedy/2024-12-22-[BOJ]-#1700-λ©€ν‹°νƒ­μŠ€μΌ€μ€„λ§.pyβ€Ž

Whitespace-only changes.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import sys
2+
input = sys.stdin.readline
3+
4+
N = int(input())
5+
meetings = []
6+
7+
for _ in range(N):
8+
start, end = map(int, input().split())
9+
meetings.append((start, end))
10+
11+
# μ’…λ£Œ μ‹œκ°„ μ˜€λ¦„μ°¨μˆœ μ •λ ¬, μ’…λ£Œ μ‹œκ°„μ΄ κ°™λ‹€λ©΄ μ‹œμž‘ μ‹œκ°„ μ˜€λ¦„μ°¨μˆœ μ •λ ¬
12+
meetings.sort(key=lambda x: (x[1], x[0]))
13+
14+
time = 0 # ν˜„μž¬ μ‹œμ  (λ§ˆμ§€λ§‰μœΌλ‘œ νšŒμ˜κ°€ λλ‚œ μ‹œκ°„)
15+
answer = 0 # λ°°μ •λœ 회의 개수
16+
17+
for meeting in meetings:
18+
if time <= meeting[0]: # ν˜„μž¬ 회의의 μ‹œμž‘ μ‹œκ°„μ΄ λ§ˆμ§€λ§‰ μ’…λ£Œ μ‹œκ°„ 이후라면
19+
time = meeting[1] # μ’…λ£Œ μ‹œκ°„μ„ κ°±μ‹ 
20+
answer += 1 # 회의 개수 증가
21+
22+
print(answer)

0 commit comments

Comments
Β (0)