ํฐ์คํ ๋ฆฌ ๋ทฐ
https://www.acmicpc.net/problem/1931
๋ฌธ์ ์ ๋๋ค
ํ๊ฐ์ ํ์์ค์ ์ต๋ค ํ์๊ฐ ์งํ๋๋๋ก ์๊ฐํ๋ฅผ ์์ฑํ๋ผ๊ณ ํฉ๋๋ค.
์ถ๊ฐ๋ก ์์์๊ฐ๊ณผ ๋์๊ฐ์ด ๊ฐ์ ์๋ ์๋ค๊ณ ํฉ๋๋ค.
์ ์ถ๋ ฅ ์กฐ๊ฑด๊ณผ ํํธ๋ ์ด๋ฌํฉ๋๋ค.
ํ์๋ฅผ ์ต๋ํ ๋ง์ด ์งํํ๊ธฐ์ํด์๋
1. ์ผ์ฐ ๋๋๋ ์์ผ๋ก ๋จผ์ ํ์๋ฅผ ์ ๋ ฌํ๊ณ
2. ์ฒซ๋ฒ์งธ(n)ํ์ ๋๋๋ ์๊ฐ <= ๋๋ฒ์งธ(n+1) ํ์ ์์ ์๊ฐ // ํด๋น ์กฐ๊ฑด์ผ๋ก ํํฐ๋ง
์ด๋ ๊ฒ ์ ๊ทผํ์์ต๋๋ค
๊ทธ๋์ ์ ๋ ฌํ ๋ฐฐ์ด์ ํฌ๋ฌธ์ผ๋ก ๋๋๋ฐ
2๋ฒ์กฐ๊ฑด์ ํด๋นํ๋ฉด countํ๋๋ก ํ์์ต๋๋ค.
import sys
n = int(input())
endPoint: int = 0
answer: int = 0
arr = []
for i in range(0,n):
a, b = map(int,sys.stdin.readline().rstrip().split())
arr.append([a,b])
arr.sort(key=lambda x: (x[1], x[0]))
for newStart, newEnd in arr:
if endPoint <= newStart:
answer += 1
endPoint = newEnd
print(answer)
๊ทธ๋์ ์ด๋ ๊ฒ ๊ตฌํํด์ฃผ์์ต๋๋ค.
์ด์คํฌ๋ฌธ์์ ๋๋ฒ์งธ ๊ฐ์ผ๋ก ์ ๋ ฌํ๋ ๋ฐฉ๋ฒ์ ๋๋ค.
arr.sort(key=lambda x: (x[1], x[0]))
์ ๋์๊ฐ๋ ๋ชจ์ต
์ด๋ ๊ฒ ์ค๋ฒ1
ํ์์ค ๋ฐฐ์ ๋ฐฑ์ค ๋ฌธ์ ํ์ดํ์ต๋๋ค.
๊ฐ์ฌํฉ๋๋ค.
- Total
- Today
- Yesterday
- swift ์๊ฐ
- swift urlcomponent encode
- swift ์์ ๊ฐ์ ธ์ค๊ธฐ
- readysay
- rag ๊ธฐ๋ฐ llm ์ฑ๋ด
- swift network refactoring
- swift urlsession network module
- llm csv
- rag ๊ธฐ๋ฐ llm
- ๋ ๋์ธ์ด ์ดํ
- swift get excel
- swift urlsession module
- swift urlsession refactoring
- ์๋์ํํธ ๋ ์ด์ธ์ด
- focus timer ์ดํ
- swift excel read
- llm pdf rag
- swift urlsession ๊ณตํตํ
- swift ๋คํธ์ํฌ ๋ชจ๋ํ
- rag llm pdf
- swift ์์ ์ฝ๊ธฐ
- ๋ ๋์ธ์ด
- swift network ๊ณตํตํ
- ๊ณต๋ถ ํ์ด๋จธ ์ดํ
- swift network module
- swift queryitem encode
- swift filemanager excel
- swift filemanager get excel
- filemanager excel read
- chatgpt rag llm
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |