id
int64 1
204
| category
stringclasses 3
values | num_cities
int64 3
6
| generation_type
stringclasses 2
values | question_ko
stringlengths 264
555
| answer_ko
stringlengths 92
269
| question_en
stringlengths 514
1.09k
| answer_en
stringlengths 167
484
| question_math
stringlengths 407
800
| answer_math
stringlengths 92
269
|
|---|---|---|---|---|---|---|---|---|---|
1
|
์ ๋ฝ
| 3
|
๋
ผ๋ฌธ ๋ฒ์ญ
|
์ด 14์ผ ๋์ ์ ๋ฝ 3๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. 6์ผ ๋์ ํผ๋ ์ฒด๋ฅผ ๋ฐฉ๋ฌธํ๊ณ ์ถ์ต๋๋ค. 9์ผ์์ 14์ผ ์ฌ์ด์ ํผ๋ ์ฒด์์ ์น๊ตฌ๋ฅผ ๋ง๋๊ณ ์ถ์ต๋๋ค. 5์ผ ๋์ ๋ฐ๋ฅด์
๋ก๋๋ฅผ ๋ฐฉ๋ฌธํ๊ณ ์ถ์ต๋๋ค. 5์ผ ๋์ ํฌ์ฑํค๋ฅผ ๋ฐฉ๋ฌธํ๊ณ ์ถ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ฐ๋ฅด์
๋ก๋์ ํผ๋ ์ฒด, ํฌ์ฑํค์ ๋ฐ๋ฅด์
๋ก๋.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 14์ผ ๋์ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ํฌ์ฑํค ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ํฌ์ฑํค์์ ๋ฐ๋ฅด์
๋ก๋๋ก ๋นํ.
5-9์ผ์ฐจ: 5์ผ๊ฐ ๋ฐ๋ฅด์
๋ก๋ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ๋ฐ๋ฅด์
๋ก๋์์ ํผ๋ ์ฒด๋ก ๋นํ.
9-14์ผ์ฐจ: 6์ผ๊ฐ ํผ๋ ์ฒด ๋ฐฉ๋ฌธ.
|
You plan to visit 3 cities in Europe for a total of 14 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to visit Florence for 6 days. You want to meet a friend in Florence between the 9th and 14th. You want to visit Barcelona for 5 days. You want to visit Helsinki for 5 days.
Here are the cities that have direct flights: Barcelona and Florence, Helsinki and Barcelona.
Plan a trip to visit all three cities in 14 days using direct flights.
|
Days 1-5: Visit Helsinki for 5 days.
Day 5: Fly from Helsinki to Barcelona.
Days 5-9: Visit Barcelona for 5 days.
Day 9: Fly from Barcelona to Florence.
Days 9-14: Visit Florence for 6 days.
|
๋ณ์ ์ ์:
H: ํฌ์ฑํค, B: ๋ฐ๋ฅด์
๋ก๋, F: ํผ๋ ์ฒด
a_H: ํฌ์ฑํค ๋์ฐฉ์ผ, d_H: ํฌ์ฑํค ์ถ๋ฐ์ผ
a_B: ๋ฐ๋ฅด์
๋ก๋ ๋์ฐฉ์ผ, d_B: ๋ฐ๋ฅด์
๋ก๋ ์ถ๋ฐ์ผ
a_F: ํผ๋ ์ฒด ๋์ฐฉ์ผ, d_F: ํผ๋ ์ฒด ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_H - a_H + 1 = 5, d_B - a_B + 1 = 5, d_F - a_F + 1 = 6
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_H, d_B, d_F) - min(a_H, a_B, a_F) + 1 = 14
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[a_F, d_F] โฉ [9, 14] โ โ
์งํญํธ์ด ์๋ ๋์:
(B โ F), (H โ B)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ํฌ์ฑํค ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ํฌ์ฑํค์์ ๋ฐ๋ฅด์
๋ก๋๋ก ๋นํ.
5-9์ผ์ฐจ: 5์ผ๊ฐ ๋ฐ๋ฅด์
๋ก๋ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ๋ฐ๋ฅด์
๋ก๋์์ ํผ๋ ์ฒด๋ก ๋นํ.
9-14์ผ์ฐจ: 6์ผ๊ฐ ํผ๋ ์ฒด ๋ฐฉ๋ฌธ.
|
2
|
์ ๋ฝ
| 3
|
๋
ผ๋ฌธ ๋ฒ์ญ
|
์ด 14์ผ ๋์ ์ ๋ฝ 3๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. 4์ผ ๋์ ๋ฐ๋์ ๋จธ๋ฌผ ์์ ์
๋๋ค. ๋ถ์ฟ ๋ ์ํฐ์ 5์ผ ๋์ ์ฒด๋ฅํ ๊ณํ์
๋๋ค. 10์ผ์์ 14์ผ ์ฌ์ด์ ๋ถ์ฟ ๋ ์ํฐ์์ ์น๊ตฌ๋ฅผ ๋ง๋๊ณ ์ถ์ต๋๋ค. 7์ผ ๋์ ๋ ์ด์บฌ๋นํฌ๋ฅผ ๋ฐฉ๋ฌธํ๊ณ ์ถ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ฐ๋๊ณผ ๋ถ์ฟ ๋ ์ํฐ, ๋ ์ด์บฌ๋นํฌ์ ๋ฐ๋.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 14์ผ ๋์ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-7์ผ์ฐจ: 7์ผ๊ฐ ๋ ์ด์บฌ๋นํฌ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ๋ ์ด์บฌ๋นํฌ์์ ๋ฐ๋์ผ๋ก ๋นํ.
7-10์ผ์ฐจ: 4์ผ๊ฐ ๋ฐ๋ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ๋ฐ๋์์ ๋ถ์ฟ ๋ ์ํฐ๋ก ๋นํ.
10-14์ผ์ฐจ: 5์ผ๊ฐ ๋ถ์ฟ ๋ ์ํฐ ๋ฐฉ๋ฌธ.
|
You plan to visit 3 cities in Europe for a total of 14 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You plan to stay in London for 4 days. You plan to stay in Bucharest for 5 days. You want to meet a friend in Bucharest between days 10 and 14. You want to visit Reykjavik for 7 days.
Here are the cities that have direct flights: London and Bucharest, and Reykjavik and London.
Plan a trip to visit all three cities in 14 days using direct flights.
|
Days 1-7: Visit Reykjavik for 7 days.
Day 7: Fly from Reykjavik to London.
Days 7-10: Visit London for 4 days.
Day 10: Fly from London to Bucharest.
Days 10-14: Visit Bucharest for 5 days.
|
๋ณ์ ์ ์:
L: ๋ฐ๋, B: ๋ถ์ฟ ๋ ์ํฐ, R: ๋ ์ด์บฌ๋นํฌ
a_L: ๋ฐ๋ ๋์ฐฉ์ผ, d_L: ๋ฐ๋ ์ถ๋ฐ์ผ
a_B: ๋ถ์ฟ ๋ ์ํฐ ๋์ฐฉ์ผ, d_B: ๋ถ์ฟ ๋ ์ํฐ ์ถ๋ฐ์ผ
a_R: ๋ ์ด์บฌ๋นํฌ ๋์ฐฉ์ผ, d_R: ๋ ์ด์บฌ๋นํฌ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_L - a_L + 1 = 4
d_B - a_B + 1 = 5
d_R - a_R + 1 = 7
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_L, d_B, d_R) - min(a_L, a_B, a_R) + 1 = 14
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[10, 14] โฉ [a_B, d_B] โ โ
์งํญํธ์ด ์๋ ๋์:
(L โ B), (R โ L)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-7์ผ์ฐจ: 7์ผ๊ฐ ๋ ์ด์บฌ๋นํฌ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ๋ ์ด์บฌ๋นํฌ์์ ๋ฐ๋์ผ๋ก ๋นํ.
7-10์ผ์ฐจ: 4์ผ๊ฐ ๋ฐ๋ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ๋ฐ๋์์ ๋ถ์ฟ ๋ ์ํฐ๋ก ๋นํ.
10-14์ผ์ฐจ: 5์ผ๊ฐ ๋ถ์ฟ ๋ ์ํฐ ๋ฐฉ๋ฌธ.
|
3
|
์ ๋ฝ
| 3
|
์ง์ ์์ฑ
|
์ด 10์ผ ๋์ ์ ๋ฝ 3๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ๋น์๋๋ฅผ 4์ผ ๋์ ๋ฐฉ๋ฌธํ๊ณ ์ถ์ต๋๋ค. ํ๋ผํ์์ 5์ผ ๋์ ๋จธ๋ฌผ๊ณ ์ถ์ต๋๋ค. 7์ผ์์ 9์ผ์ ์ฌ์ด์ ํ๋ผํ์์ ์น์ฒ์ ๋ง๋๊ธฐ๋ก ํ์ต๋๋ค. 3์ผ ๋์ ๋ถ๋คํ์คํธ๋ฅผ ์ฌํํ๊ณ ์ถ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋น์๋์ ํ๋ผํ, ๋ถ๋คํ์คํธ์ ๋น์๋.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 10์ผ ๋์ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋ถ๋คํ์คํธ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋ถ๋คํ์คํธ์์ ๋น์๋๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ๋น์๋ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋น์๋์์ ํ๋ผํ๋ก ๋นํ.
6-10์ผ์ฐจ: 5์ผ๊ฐ ํ๋ผํ ๋ฐฉ๋ฌธ.
|
You plan to visit 3 cities in Europe for a total of 10 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to visit Vienna for 4 days. You want to stay in Prague for 5 days. You are meeting a relative in Prague between the 7th and the 9th. You want to travel to Budapest for 3 days.
Here are the cities that have direct flights: Vienna and Prague, Budapest and Vienna.
Plan a trip to visit the three cities in 10 days using direct flights.
|
Days 1-3: Visit Budapest for 3 days.
Day 3: Fly from Budapest to Vienna.
Days 3-6: Visit Vienna for 4 days.
Day 6: Fly from Vienna to Prague.
Days 6-10: Visit Prague for 5 days.
|
๋ณ์ ์ ์:
V: ๋น์๋, P: ํ๋ผํ, B: ๋ถ๋คํ์คํธ
a_V: ๋น์๋ ๋์ฐฉ์ผ, d_V: ๋น์๋ ์ถ๋ฐ์ผ
a_P: ํ๋ผํ ๋์ฐฉ์ผ, d_P: ํ๋ผํ ์ถ๋ฐ์ผ
a_B: ๋ถ๋คํ์คํธ ๋์ฐฉ์ผ, d_B: ๋ถ๋คํ์คํธ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_V - a_V + 1 = 4
d_P - a_P + 1 = 5
d_B - a_B + 1 = 3
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_V, d_P, d_B) - min(a_V, a_P, a_B) + 1 = 10
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[7, 9] โฉ [a_P, d_P] โ โ
์งํญํธ์ด ์๋ ๋์:
(V โ P), (B โ V)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋ถ๋คํ์คํธ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋ถ๋คํ์คํธ์์ ๋น์๋๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ๋น์๋ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋น์๋์์ ํ๋ผํ๋ก ๋นํ.
6-10์ผ์ฐจ: 5์ผ๊ฐ ํ๋ผํ ๋ฐฉ๋ฌธ.
|
4
|
์ ๋ฝ
| 3
|
์ง์ ์์ฑ
|
์ด 12์ผ ๋์ ์ ๋ฝ 3๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์ธํฐ๋ผ์ผ์์ 3์ผ ๋์ ์ฌํ์ ํ ์์ ์
๋๋ค. ํ๋ฆฌ์์ 5์ผ ๋์ ์ฒด๋ฅํ ์์ ์
๋๋ค. ๋ก๋ง์์ 6์ผ ๋์ ๋จธ๋ฌด๋ฅผ ์์ ์
๋๋ค. 2-3์ผ์ ๋ก๋ง์์ ์งํํ๋ ํํ์ ์ฐธ์ํด์ผ ํฉ๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ์ธํฐ๋ผ์ผ๊ณผ ๋ก๋ง, ํ๋ฆฌ์ ์ธํฐ๋ผ์ผ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 12์ผ ๋์ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-6์ผ์ฐจ: 6์ผ๊ฐ ๋ก๋ง ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋ก๋ง์์ ์ธํฐ๋ผ์ผ์ผ๋ก ๋นํ.
6-8์ผ์ฐจ: 3์ผ๊ฐ ์ธํฐ๋ผ์ผ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ์ธํฐ๋ผ์ผ์์ ํ๋ฆฌ๋ก ๋นํ.
8-12์ผ์ฐจ: 5์ผ๊ฐ ํ๋ฆฌ ๋ฐฉ๋ฌธ.
|
You plan to visit 3 cities in Europe for a total of 12 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You are planning to travel in Interlaken for 3 days. You'll be in Paris for 5 days. You'll be in Rome for 6 days. You need to attend a conference in Rome on days 2-3.
Here are the cities that have direct flights: Interlaken and Rome, Paris and Interlaken.
Plan a trip to visit the three cities in 12 days using direct flights.
|
Days 1-6: Visit Rome for 6 days.
Day 6: Fly from Rome to Interlaken.
Days 6-8: Visit Interlaken for 3 days.
Day 8: Fly from Interlaken to Paris.
Days 8-12: Visit Paris for 5 days.
|
๋ณ์ ์ ์:
I: ์ธํฐ๋ผ์ผ, P: ํ๋ฆฌ, R: ๋ก๋ง
a_I: ์ธํฐ๋ผ์ผ ๋์ฐฉ์ผ, d_I: ์ธํฐ๋ผ์ผ ์ถ๋ฐ์ผ
a_P: ํ๋ฆฌ ๋์ฐฉ์ผ, d_P: ํ๋ฆฌ ์ถ๋ฐ์ผ
a_R: ๋ก๋ง ๋์ฐฉ์ผ, d_R: ๋ก๋ง ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_I - a_I + 1 = 3
d_P - a_P + 1 = 5
d_R - a_R + 1 = 6
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_I, d_P, d_R) - min(a_I, a_P, a_R) + 1 = 12
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
{2, 3} โ [a_R, d_R]
์งํญํธ์ด ์๋ ๋์:
(I โ R), (P โ I)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-6์ผ์ฐจ: 6์ผ๊ฐ ๋ก๋ง ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋ก๋ง์์ ์ธํฐ๋ผ์ผ์ผ๋ก ๋นํ.
6-8์ผ์ฐจ: 3์ผ๊ฐ ์ธํฐ๋ผ์ผ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ์ธํฐ๋ผ์ผ์์ ํ๋ฆฌ๋ก ๋นํ.
8-12์ผ์ฐจ: 5์ผ๊ฐ ํ๋ฆฌ ๋ฐฉ๋ฌธ.
|
5
|
์ ๋ฝ
| 4
|
์ง์ ์์ฑ
|
์ด 11์ผ ๋์ ์ ๋ฝ 4๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ํ๋ฆฌ์์ 5์ผ๊ฐ ๋จธ๋ฌผ ๊ณํ์
๋๋ค. ๋ฐ๋ผ๋
ธ์์ 5์ผ์ ๋ณด๋ผ ์์ ์
๋๋ค. 6-8์ผ์๋ ๋ฐ๋ผ๋
ธ์์ ์งํ๋๋ ํจ์
์ผ๋ฅผ ๋ณด๋ ค๊ณ ํฉ๋๋ค. 2์ผ ๋์ ํ๋ํฌํธ๋ฅดํธ๋ฅผ ๋ฐฉ๋ฌธํ๊ณ ์ถ์ต๋๋ค. ๊ทธ๋ฆฐ๋ธ๋ฐํธ ๋ํ 2์ผ ๋์ ๋ฐฉ๋ฌธํ๊ณ ์ถ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ฐ๋ผ๋
ธ์ ํ๋ฆฌ, ๊ทธ๋ฆฐ๋ธ๋ฐํธ์ ๋ฐ๋ผ๋
ธ, ํ๋ํฌํธ๋ฅดํธ์ ํ๋ฆฌ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 11์ผ ๋์ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ํ๋ํฌํธ๋ฅดํธ ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ํ๋ํฌํธ๋ฅดํธ์์ ํ๋ฆฌ๋ก ๋นํ.
2-6์ผ์ฐจ: 5์ผ๊ฐ ํ๋ฆฌ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ํ๋ฆฌ์์ ๋ฐ๋ผ๋
ธ๋ก ๋นํ.
6-10์ผ์ฐจ: 5์ผ๊ฐ ๋ฐ๋ผ๋
ธ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ๋ฐ๋ผ๋
ธ์์ ๊ทธ๋ฆฐ๋ธ๋ฐํธ๋ก ๋นํ.
10-11์ผ์ฐจ: 2์ผ๊ฐ ๊ทธ๋ฆฐ๋ธ๋ฐํธ ๋ฐฉ๋ฌธ.
|
You plan to visit 4 cities in Europe for a total of 11 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You plan to spend 5 days in Paris. You plan to spend 5 days in Milan. On days 6-8, you want to see a fashion show in Milan. You want to visit Frankfurt for 2 days. You also want to visit Grindelwald for 2 days.
Here are the cities that have direct flights: Milan and Paris, Grindelwald and Milan, Frankfurt and Paris.
Plan a trip to visit four cities in 11 days using direct flights.
|
Day 1-2: Visit Frankfurt for 2 days.
Day 2: Fly from Frankfurt to Paris.
Days 2-6: Visit Paris for 5 days.
Day 6: Fly from Paris to Milan.
Days 6-10: Visit Milan for 5 days.
Day 10: Fly from Milan to Grindelwald.
Days 10-11: Visit Grindelwald for 2 days.
|
๋ณ์ ์ ์:
P: ํ๋ฆฌ, M: ๋ฐ๋ผ๋
ธ, F: ํ๋ํฌํธ๋ฅดํธ, G: ๊ทธ๋ฆฐ๋ธ๋ฐํธ
a_P: ํ๋ฆฌ ๋์ฐฉ์ผ, d_P: ํ๋ฆฌ ์ถ๋ฐ์ผ
a_M: ๋ฐ๋ผ๋
ธ ๋์ฐฉ์ผ, d_M: ๋ฐ๋ผ๋
ธ ์ถ๋ฐ์ผ
a_F: ํ๋ํฌํธ๋ฅดํธ ๋์ฐฉ์ผ, d_F: ํ๋ํฌํธ๋ฅดํธ ์ถ๋ฐ์ผ
a_G: ๊ทธ๋ฆฐ๋ธ๋ฐํธ ๋์ฐฉ์ผ, d_G: ๊ทธ๋ฆฐ๋ธ๋ฐํธ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_P - a_P + 1 = 5
d_M - a_M + 1 = 5
d_F - a_F + 1 = 2
d_G - a_G + 1 = 2
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_P, d_M, d_F, d_G) - min(a_P, a_M, a_F, a_G) + 1 = 11
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[6, 8] โฉ [a_M, d_M] โ โ
์งํญํธ์ด ์๋ ๋์:
(M โ P), (G โ M), (F โ P)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ํ๋ํฌํธ๋ฅดํธ ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ํ๋ํฌํธ๋ฅดํธ์์ ํ๋ฆฌ๋ก ๋นํ.
2-6์ผ์ฐจ: 5์ผ๊ฐ ํ๋ฆฌ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ํ๋ฆฌ์์ ๋ฐ๋ผ๋
ธ๋ก ๋นํ.
6-10์ผ์ฐจ: 5์ผ๊ฐ ๋ฐ๋ผ๋
ธ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ๋ฐ๋ผ๋
ธ์์ ๊ทธ๋ฆฐ๋ธ๋ฐํธ๋ก ๋นํ.
10-11์ผ์ฐจ: 2์ผ๊ฐ ๊ทธ๋ฆฐ๋ธ๋ฐํธ ๋ฐฉ๋ฌธ.
|
6
|
์ ๋ฝ
| 4
|
์ง์ ์์ฑ
|
์ด 12์ผ ๋์ ์ ๋ฝ 4๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ํจ๋ถ๋ฅดํฌ์์ 6์ผ ๋์ ์ฌํ์ ํ๊ณ ์ถ์ต๋๋ค. ๋ฃฉ์
๋ถ๋ฅดํฌ์์๋ 2์ผ๊ฐ ๋จธ๋ฌผ๊ณ ์ถ์ต๋๋ค. 4-7์ผ ์ฌ์ด์ ์งํ๋๋ ์์คํ
๋ฅด๋ด์ ํค๋ฆฝ ์ถ์ ์ ๋งค์ผ ๋ฐฉ๋ฌธํ๋ ค๊ณ ํฉ๋๋ค. ์์คํ
๋ฅด๋ด์์๋ 4์ผ๊ฐ ์ฌํ์ ํ ์์ ์
๋๋ค. ๋ธ๋คผ์
์์๋ 3์ผ๊ฐ ๋จธ๋ฌผ๊ณ ์ ํฉ๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ธ๋คผ์
๊ณผ ๋ฃฉ์
๋ถ๋ฅดํฌ, ํจ๋ถ๋ฅดํฌ์ ์์คํ
๋ฅด๋ด, ๋ธ๋ฆฌ์๊ณผ ์์คํ
๋ฅด๋ด.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 12์ผ ๋์ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ๋ฃฉ์
๋ถ๋ฅดํฌ ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ๋ฃฉ์
๋ถ๋ฅดํฌ์์ ๋ธ๋คผ์
๋ก ๋นํ.
2-4์ผ์ฐจ: 3์ผ๊ฐ ๋ธ๋คผ์
๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ๋ธ๋คผ์
์์ ์์คํ
๋ฅด๋ด์ผ๋ก ๋นํ.
4-7์ผ์ฐจ: 4์ผ๊ฐ ์์คํ
๋ฅด๋ด ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ์์คํ
๋ฅด๋ด์์ ํจ๋ถ๋ฅดํฌ๋ก ๋นํ.
7-12์ผ์ฐจ: 6์ผ๊ฐ ํจ๋ถ๋ฅดํฌ ๋ฐฉ๋ฌธ.
|
You plan to visit 4 cities in Europe for a total of 12 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to spend 6 days in Hamburg. In Luxembourg, you want to spend 2 days. You want to visit the Tulip Festival in Amsterdam every day between days 4-7. In Amsterdam, you want to spend 4 days traveling. You want to spend 3 days in Brussels.
Here are the cities that have direct flights: Brussels and Luxembourg, Hamburg and Amsterdam, Brussels and Amsterdam.
Plan a trip to visit the four cities in 12 days using direct flights.
|
Day 1-2: Visit Luxembourg for 2 days.
Day 2: Fly from Luxembourg to Brussels.
Days 2-4: Visit Brussels for 3 days.
Day 4: Fly from Brussels to Amsterdam.
Days 4-7: Visit Amsterdam for 4 days.
Day 7: Fly from Amsterdam to Hamburg.
Days 7-12: Visit Hamburg for 6 days.
|
๋ณ์ ์ ์:
H: ํจ๋ถ๋ฅดํฌ, L: ๋ฃฉ์
๋ถ๋ฅดํฌ, A: ์์คํ
๋ฅด๋ด, B: ๋ธ๋คผ์
a_H: ํจ๋ถ๋ฅดํฌ ๋์ฐฉ์ผ, d_H: ํจ๋ถ๋ฅดํฌ ์ถ๋ฐ์ผ
a_L: ๋ฃฉ์
๋ถ๋ฅดํฌ ๋์ฐฉ์ผ, d_L: ๋ฃฉ์
๋ถ๋ฅดํฌ ์ถ๋ฐ์ผ
a_A: ์์คํ
๋ฅด๋ด ๋์ฐฉ์ผ, d_A: ์์คํ
๋ฅด๋ด ์ถ๋ฐ์ผ
a_B: ๋ธ๋คผ์
๋์ฐฉ์ผ, d_B: ๋ธ๋คผ์
์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_H - a_H + 1 = 6
d_L - a_L + 1 = 2
d_A - a_A + 1 = 4
d_B - a_B + 1 = 3
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_H, d_L, d_A, d_B) - min(a_H, a_L, a_A, a_B) + 1 = 12
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[4, 7] โ [a_A, d_A]
์งํญํธ์ด ์๋ ๋์:
(B โ L), (H โ A), (B โ A)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ๋ฃฉ์
๋ถ๋ฅดํฌ ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ๋ฃฉ์
๋ถ๋ฅดํฌ์์ ๋ธ๋คผ์
๋ก ๋นํ.
2-4์ผ์ฐจ: 3์ผ๊ฐ ๋ธ๋คผ์
๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ๋ธ๋คผ์
์์ ์์คํ
๋ฅด๋ด์ผ๋ก ๋นํ.
4-7์ผ์ฐจ: 4์ผ๊ฐ ์์คํ
๋ฅด๋ด ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ์์คํ
๋ฅด๋ด์์ ํจ๋ถ๋ฅดํฌ๋ก ๋นํ.
7-12์ผ์ฐจ: 6์ผ๊ฐ ํจ๋ถ๋ฅดํฌ ๋ฐฉ๋ฌธ.
|
7
|
์ ๋ฝ
| 4
|
์ง์ ์์ฑ
|
์ด 14์ผ ๋์ ์ ๋ฝ 4๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. 6์ผ ๋์ ๋น์ ๋ฐฉ๋ฌธํ๊ณ ์ถ์ต๋๋ค. ๋น์ด ์ฌํ์ ๋ง์ง๋ง ์ฌ์ ์ง์์ผ๋ฉด ์ข๊ฒ ์ต๋๋ค. ์คํกํ๋กฌ์์ 4์ผ๊ฐ ๋จธ๋ฌด๋ฅผ ๊ณํ์
๋๋ค. ๋ฒ ๋ฅผ๋ฆฐ์์ 3์ผ ๋์ ์ฌํ์ ์ฆ๊ธฐ๊ณ ์ถ์ต๋๋ค. ์ฌํ 8์ผ์งธ์ ๋ฒ ๋ฅผ๋ฆฐ์์ ์ถ๊ตฌ ์ง๊ด์ ํ๊ณ ์ถ์ต๋๋ค. ์ฝํํ๊ฒ์์ 4์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ฒ ๋ฅผ๋ฆฐ๊ณผ ์ฝํํ๊ฒ, ๋น๊ณผ ๋ฒ ๋ฅผ๋ฆฐ, ์คํกํ๋กฌ๊ณผ ์ฝํํ๊ฒ, ์ฝํํ๊ฒ๊ณผ ๋น.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 14์ผ ๋์ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ์คํกํ๋กฌ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ์คํกํ๋กฌ์์ ์ฝํํ๊ฒ์ผ๋ก ๋นํ.
4-7์ผ์ฐจ: 4์ผ๊ฐ ์ฝํํ๊ฒ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ์ฝํํ๊ฒ์์ ๋ฒ ๋ฅผ๋ฆฐ์ผ๋ก ๋นํ.
7-9์ผ์ฐจ: 3์ผ๊ฐ ๋ฒ ๋ฅผ๋ฆฐ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ๋ฒ ๋ฅผ๋ฆฐ์์ ๋น์ผ๋ก ๋นํ.
9-14์ผ์ฐจ: 6์ผ๊ฐ ๋น ๋ฐฉ๋ฌธ.
|
You plan to visit 4 cities in Europe for a total of 14 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to visit Vienna for 6 days. You want Vienna to be the last stop on your trip. You plan to spend 4 days in Stockholm. You want to spend 3 days in Berlin. You want to see a soccer game in Berlin on the 8th day of your trip. You want to spend 4 days in Copenhagen.
Here are the cities that have direct flights: Berlin and Copenhagen, Vienna and Berlin, Stockholm and Copenhagen, Copenhagen and Vienna.
Plan a trip to visit four cities in 14 days using direct flights.
|
Days 1-4: Visit Stockholm for 4 days.
Day 4: Fly from Stockholm to Copenhagen.
Days 4-7: Visit Copenhagen for 4 days.
Day 7: Fly from Copenhagen to Berlin.
Days 7-9: Visit Berlin for 3 days.
Day 9: Fly from Berlin to Vienna.
Days 9-14: Visit Vienna for 6 days.
|
๋ณ์ ์ ์:
V: ๋น, S: ์คํกํ๋กฌ, B: ๋ฒ ๋ฅผ๋ฆฐ, C: ์ฝํํ๊ฒ
a_V: ๋น ๋์ฐฉ์ผ, d_V: ๋น ์ถ๋ฐ์ผ
a_S: ์คํกํ๋กฌ ๋์ฐฉ์ผ, d_S: ์คํกํ๋กฌ ์ถ๋ฐ์ผ
a_B: ๋ฒ ๋ฅผ๋ฆฐ ๋์ฐฉ์ผ, d_B: ๋ฒ ๋ฅผ๋ฆฐ ์ถ๋ฐ์ผ
a_C: ์ฝํํ๊ฒ ๋์ฐฉ์ผ, d_C: ์ฝํํ๊ฒ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_V - a_V + 1 = 6
d_S - a_S + 1 = 4
d_B - a_B + 1 = 3
d_C - a_C + 1 = 4
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_V, d_S, d_B, d_C) - min(a_V, a_S, a_B, a_C) + 1 = 14
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
d_V = 14
a_B โค 8 โค d_B
์งํญํธ์ด ์๋ ๋์:
(B โ C), (V โ B), (S โ C), (C โ V)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ์คํกํ๋กฌ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ์คํกํ๋กฌ์์ ์ฝํํ๊ฒ์ผ๋ก ๋นํ.
4-7์ผ์ฐจ: 4์ผ๊ฐ ์ฝํํ๊ฒ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ์ฝํํ๊ฒ์์ ๋ฒ ๋ฅผ๋ฆฐ์ผ๋ก ๋นํ.
7-9์ผ์ฐจ: 3์ผ๊ฐ ๋ฒ ๋ฅผ๋ฆฐ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ๋ฒ ๋ฅผ๋ฆฐ์์ ๋น์ผ๋ก ๋นํ.
9-14์ผ์ฐจ: 6์ผ๊ฐ ๋น ๋ฐฉ๋ฌธ.
|
8
|
์ ๋ฝ
| 4
|
์ง์ ์์ฑ
|
์ด 13์ผ ๋์ ์ ๋ฝ 4๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์๊ทธ๋ ๋ธ์์ 3์ผ๊ฐ ๋จธ๋ฌผ๊ณ ์ถ์ต๋๋ค. ๋ฐ๋ฅด์ค๋ฐ์์๋ 3์ผ๊ฐ ๋จธ๋ฌผ๊ณ ์ถ์ต๋๋ค. ๋ฐ๋ฅด์ค๋ฐ์์ ์ฌํ 2์ผ์ฐจ์ ์น๊ตฌ์ ์์ฌ๋ฅผ ํ๊ธฐ๋ก ํ์ต๋๋ค. ๋ถ๋คํ์คํธ์์ 6์ผ์ ๋จธ๋ฌด๋ฅด๊ณ ์ถ์ต๋๋ค. ๋ถ์ฟ ๋ ์ํฐ์์ 4์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. 11์ผ์์ 12์ผ ์ฌ์ด์ ๋ถ์ฟ ๋ ์ํฐ์ ์๋ ์ฌ์ด์ ์ง์ ๋๋ฌ๊ฐ ์์ ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ์๊ทธ๋ ๋ธ์ ๋ถ๋คํ์คํธ, ๋ฐ๋ฅด์ค๋ฐ์ ๋ถ๋คํ์คํธ, ๋ถ์ฟ ๋ ์ํฐ์ ์๊ทธ๋ ๋ธ, ๋ถ์ฟ ๋ ์ํฐ์ ๋ถ๋คํ์คํธ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 13์ผ ๋์ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋ฐ๋ฅด์ค๋ฐ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋ฐ๋ฅด์ค๋ฐ์์ ๋ถ๋คํ์คํธ๋ก ๋นํ.
3-8์ผ์ฐจ: 6์ผ๊ฐ ๋ถ๋คํ์คํธ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ๋ถ๋คํ์คํธ์์ ์๊ทธ๋ ๋ธ๋ก ๋นํ.
8-10์ผ์ฐจ: 3์ผ๊ฐ ์๊ทธ๋ ๋ธ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ์๊ทธ๋ ๋ธ์์ ๋ถ์ฟ ๋ ์ํฐ๋ก ๋นํ.
10-13์ผ์ฐจ: 4์ผ๊ฐ ๋ถ์ฟ ๋ ์ํฐ ๋ฐฉ๋ฌธ.
|
You plan to visit 4 cities in Europe for a total of 13 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to spend 3 days in Zagreb. You also want to spend 3 days in Warsaw. You want to have dinner with a friend in Warsaw on day 2 of your trip. You want to spend 6 days in Budapest. You want to spend 4 days in Bucharest. You plan to go to your cousin's house in Bucharest between the 11th and 12th.
Here are the cities that have direct flights: Zagreb and Budapest, Warsaw and Budapest, Bucharest and Zagreb, Bucharest and Budapest.
Plan a trip to visit four cities in 13 days using direct flights.
|
Days 1-3: Visit Warsaw for 3 days.
Day 3: Fly from Warsaw to Budapest.
Days 3-8: Visit Budapest for 6 days.
Day 8: Fly from Budapest to Zagreb.
Days 8-10: Visit Zagreb for 3 days.
Day 10: Fly from Zagreb to Bucharest.
Days 10-13: Visit Bucharest for 4 days.
|
๋ณ์ ์ ์:
Z: ์๊ทธ๋ ๋ธ, W: ๋ฐ๋ฅด์ค๋ฐ, B: ๋ถ๋คํ์คํธ, R: ๋ถ์ฟ ๋ ์ํฐ
a_Z: ์๊ทธ๋ ๋ธ ๋์ฐฉ์ผ, d_Z: ์๊ทธ๋ ๋ธ ์ถ๋ฐ์ผ
a_W: ๋ฐ๋ฅด์ค๋ฐ ๋์ฐฉ์ผ, d_W: ๋ฐ๋ฅด์ค๋ฐ ์ถ๋ฐ์ผ
a_B: ๋ถ๋คํ์คํธ ๋์ฐฉ์ผ, d_B: ๋ถ๋คํ์คํธ ์ถ๋ฐ์ผ
a_R: ๋ถ์ฟ ๋ ์ํฐ ๋์ฐฉ์ผ, d_R: ๋ถ์ฟ ๋ ์ํฐ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_Z - a_Z + 1 = 3
d_W - a_W + 1 = 3
d_B - a_B + 1 = 6
d_R - a_R + 1 = 4
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_Z, d_W, d_B, d_R) - min(a_Z, a_W, a_B, a_R) + 1 = 13
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
a_W โค 2 โค d_W
[11, 12] โฉ [a_R, d_R] โ โ
์งํญํธ์ด ์๋ ๋์:
(Z โ B), (W โ B), (R โ Z), (R โ B)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋ฐ๋ฅด์ค๋ฐ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋ฐ๋ฅด์ค๋ฐ์์ ๋ถ๋คํ์คํธ๋ก ๋นํ.
3-8์ผ์ฐจ: 6์ผ๊ฐ ๋ถ๋คํ์คํธ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ๋ถ๋คํ์คํธ์์ ์๊ทธ๋ ๋ธ๋ก ๋นํ.
8-10์ผ์ฐจ: 3์ผ๊ฐ ์๊ทธ๋ ๋ธ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ์๊ทธ๋ ๋ธ์์ ๋ถ์ฟ ๋ ์ํฐ๋ก ๋นํ.
10-13์ผ์ฐจ: 4์ผ๊ฐ ๋ถ์ฟ ๋ ์ํฐ ๋ฐฉ๋ฌธ.
|
9
|
์ ๋ฝ
| 5
|
์ง์ ์์ฑ
|
์ด 13์ผ ๋์ ์ ๋ฝ 5๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ๋ง๋ฅด์ธ์ ์์ 4์ผ์ ์ง๋ผ ์์ ์
๋๋ค. 6์ผ๋ถํฐ 8์ผ ์ฌ์ด์ ๋ง๋ฅด์ธ์ ์์ ์ด๋ฆฌ๋ ์คํ๋ผ ๊ณต์ฐ์ ๋ณด๊ณ ์ํฉ๋๋ค. ํฌ๋ฅดํฌ๋ฅผ 4์ผ ๋์ ์ฌํํ๊ณ ์ถ์ต๋๋ค. ๋ฒ ๋ฅธ์์ 2์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. ๋๋ฅธ๋ฒ ๋ฅดํฌ์์ 4์ผ๊ฐ ๋จธ๋ฌผ ๊ฒ์
๋๋ค. 11-13์ผ ์ฌ์ด์ ๋๋ฅธ๋ฒ ๋ฅดํฌ์์ ์น๊ตฌ๋ฅผ ๋ง๋๊ณ ์ ํฉ๋๋ค. ๋ง๋๋ฆฌ๋๋ฅผ 3์ผ ๋์ ๋๋ฌ๋ณผ ์์ ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ง๋๋ฆฌ๋์ ๋ง๋ฅด์ธ์ , ๋ฒ ๋ฅธ๊ณผ ๋ง๋ฅด์ธ์ , ๋๋ฅธ๋ฒ ๋ฅดํฌ์ ๋ฒ ๋ฅธ, ํฌ๋ฅดํฌ์ ๋ง๋๋ฆฌ๋.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 13์ผ ๋์ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ํฌ๋ฅดํฌ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ํฌ๋ฅดํฌ์์ ๋ง๋๋ฆฌ๋๋ก ๋นํ.
4-6์ผ์ฐจ: 3์ผ๊ฐ ๋ง๋๋ฆฌ๋ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋ง๋๋ฆฌ๋์์ ๋ง๋ฅด์ธ์ ๋ก ๋นํ.
6-9์ผ์ฐจ: 4์ผ๊ฐ ๋ง๋ฅด์ธ์ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ๋ง๋ฅด์ธ์ ์์ ๋ฒ ๋ฅธ์ผ๋ก ๋นํ.
9-10์ผ์ฐจ: 2์ผ๊ฐ ๋ฒ ๋ฅธ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ๋ฒ ๋ฅธ์์ ๋๋ฅธ๋ฒ ๋ฅดํฌ๋ก ๋นํ.
10-13์ผ์ฐจ: 4์ผ๊ฐ ๋๋ฅธ๋ฒ ๋ฅดํฌ ๋ฐฉ๋ฌธ.
|
You plan to visit 5 cities in Europe for a total of 13 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You plan to spend 4 days in Marseille. You want to see an opera performance in Marseille between the 6th and 8th. You want to travel to Porto for 4 days. You want to spend 2 days in Bern. You want to spend 4 days in Nuremberg. You want to meet a friend in Nuremberg between the 11th and 13th. You want to spend 3 days exploring Madrid.
Here are the cities that have direct flights: Madrid and Marseille, Bern and Marseille, Nuremberg and Bern, Porto and Madrid.
Plan a trip to visit five cities in 13 days using direct flights.
|
Days 1-4: Visit Porto for 4 days.
Day 4: Fly from Porto to Madrid.
Days 4-6: Visit Madrid for 3 days.
Day 6: Fly from Madrid to Marseille.
Days 6-9: Visit Marseille for 4 days.
Day 9: Fly from Marseille to Bern.
Days 9-10: Visit Bern for 2 days.
Day 10: Fly from Bern to Nuremberg.
Days 10-13: Visit Nuremberg for 4 days.
|
๋ณ์ ์ ์:
Ms: ๋ง๋ฅด์ธ์ , P: ํฌ๋ฅดํฌ, B: ๋ฒ ๋ฅธ, N: ๋๋ฅธ๋ฒ ๋ฅดํฌ, Md: ๋ง๋๋ฆฌ๋
a_Ms: ๋ง๋ฅด์ธ์ ๋์ฐฉ์ผ, d_Ms: ๋ง๋ฅด์ธ์ ์ถ๋ฐ์ผ
a_P: ํฌ๋ฅดํฌ ๋์ฐฉ์ผ, d_P: ํฌ๋ฅดํฌ ์ถ๋ฐ์ผ
a_B: ๋ฒ ๋ฅธ ๋์ฐฉ์ผ, d_B: ๋ฒ ๋ฅธ ์ถ๋ฐ์ผ
a_N: ๋๋ฅธ๋ฒ ๋ฅดํฌ ๋์ฐฉ์ผ, d_N: ๋๋ฅธ๋ฒ ๋ฅดํฌ ์ถ๋ฐ์ผ
a_Md: ๋ง๋๋ฆฌ๋ ๋์ฐฉ์ผ, d_Md: ๋ง๋๋ฆฌ๋ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_Ms - a_Ms + 1 = 4
d_P - a_P + 1 = 4
d_B - a_B + 1 = 2
d_N - a_N + 1 = 4
d_Md - a_Md + 1 = 3
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_Ms, d_P, d_B, d_N, d_Md) - min(a_Ms, a_P, a_B, a_N, a_Md) + 1 = 13
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[6, 8] โฉ [a_Ms, d_Ms] โ โ
[11, 13] โฉ [a_N, d_N] โ โ
์งํญํธ์ด ์๋ ๋์:
(Md โ Ms), (B โ Ms), (N โ B), (P โ Md)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ํฌ๋ฅดํฌ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ํฌ๋ฅดํฌ์์ ๋ง๋๋ฆฌ๋๋ก ๋นํ.
4-6์ผ์ฐจ: 3์ผ๊ฐ ๋ง๋๋ฆฌ๋ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋ง๋๋ฆฌ๋์์ ๋ง๋ฅด์ธ์ ๋ก ๋นํ.
6-9์ผ์ฐจ: 4์ผ๊ฐ ๋ง๋ฅด์ธ์ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ๋ง๋ฅด์ธ์ ์์ ๋ฒ ๋ฅธ์ผ๋ก ๋นํ.
9-10์ผ์ฐจ: 2์ผ๊ฐ ๋ฒ ๋ฅธ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ๋ฒ ๋ฅธ์์ ๋๋ฅธ๋ฒ ๋ฅดํฌ๋ก ๋นํ.
10-13์ผ์ฐจ: 4์ผ๊ฐ ๋๋ฅธ๋ฒ ๋ฅดํฌ ๋ฐฉ๋ฌธ.
|
10
|
์ ๋ฝ
| 5
|
์ง์ ์์ฑ
|
์ด 16์ผ ๋์ ์ ๋ฝ 5๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์ธํฐ๋ผ์ผ์์ 4์ผ๊ฐ ๋จธ๋ฌด๋ฅด๋ ค ํฉ๋๋ค. ๋ฐ๋์์๋ 5์ผ๊ฐ ๋จธ๋ฌด๋ฅด๋ ค๊ณ ํฉ๋๋ค. 2์ผ์งธ์ 4์ผ์งธ ์ฌ์ด์ ๋ฐ๋์์ ์ฝ์ํธ๋ฅผ ์ฆ๊ธธ ์์ ์
๋๋ค. ๋ก๋ง๋ฅผ 5์ผ ๋์ ์ฆ๊ธฐ๊ณ ์ถ์ต๋๋ค. ๋ฒ ๋์ค์์๋ 3์ผ ๋์ ์์ ์์ ์
๋๋ค. 12์ผ์ฐจ์ ๋ฒ ๋์ค์์ ์น์ ์ ๋ง๋๊ธฐ๋ก ํ์ต๋๋ค. ํ๋ฆฌ์์ 3์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. 4์ผ๊ฐ ์ธํฐ๋ผ์ผ์์ ์ฌํ์ ์ฆ๊ธฐ๋ ค๊ณ ํฉ๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ํ๋ฆฌ์ ๋ฐ๋, ์ธํฐ๋ผ์ผ๊ณผ ๋ฒ ๋์ค, ๋ก๋ง์ ํ๋ฆฌ, ๋ฒ ๋์ค์ ๋ก๋ง, ๋ฐ๋๊ณผ ๋ฒ ๋์ค, ์ธํฐ๋ผ์ผ๊ณผ ๋ก๋ง.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 16์ผ ๋์ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ๋ฐ๋ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋ฐ๋์์ ํ๋ฆฌ๋ก ๋นํ.
5-7์ผ์ฐจ: 3์ผ๊ฐ ํ๋ฆฌ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ํ๋ฆฌ์์ ๋ก๋ง๋ก ๋นํ.
7-11์ผ์ฐจ: 5์ผ๊ฐ ๋ก๋ง ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ๋ก๋ง์์ ๋ฒ ๋์ค์ผ๋ก ๋นํ.
11-13์ผ์ฐจ: 3์ผ๊ฐ ๋ฒ ๋์ค ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ๋ฒ ๋์ค์์ ์ธํฐ๋ผ์ผ๋ก ๋นํ.
13-16์ผ์ฐจ: 4์ผ๊ฐ ์ธํฐ๋ผ์ผ ๋ฐฉ๋ฌธ.
|
You plan to visit 5 cities in Europe for a total of 16 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You plan to spend 4 days in Interlaken. You plan to spend 5 days in London. You plan to enjoy a concert in London between days 2 and 4. You want to spend 5 days in Rome. You plan to be in Venice for 3 days. You plan to meet a relative in Venice on day 12. You want to spend 3 days in Paris. You want to spend 4 days in Interlaken.
Here are the cities that have direct flights: Paris and London, Interlaken and Venice, Rome and Paris, Venice and Rome, London and Venice, Interlaken and Rome.
Plan a trip to visit five cities in 16 days using direct flights.
|
Days 1-5: Visit London for 5 days.
Day 5: Fly from London to Paris.
Days 5-7: Visit Paris for 3 days.
Day 7: Fly from Paris to Rome.
Days 7-11: Visit Rome for 5 days.
Day 11: Fly from Rome to Venice.
Days 11-13: Visit Venice for 3 days.
Day 13: Fly from Venice to Interlaken.
Days 13-16: Visit Interlaken for 4 days.
|
๋ณ์ ์ ์:
I: ์ธํฐ๋ผ์ผ, L: ๋ฐ๋, R: ๋ก๋ง, V: ๋ฒ ๋์ค, P: ํ๋ฆฌ
a_I: ์ธํฐ๋ผ์ผ ๋์ฐฉ์ผ, d_I: ์ธํฐ๋ผ์ผ ์ถ๋ฐ์ผ
a_L: ๋ฐ๋ ๋์ฐฉ์ผ, d_L: ๋ฐ๋ ์ถ๋ฐ์ผ
a_R: ๋ก๋ง ๋์ฐฉ์ผ, d_R: ๋ก๋ง ์ถ๋ฐ์ผ
a_V: ๋ฒ ๋์ค ๋์ฐฉ์ผ, d_V: ๋ฒ ๋์ค ์ถ๋ฐ์ผ
a_P: ํ๋ฆฌ ๋์ฐฉ์ผ, d_P: ํ๋ฆฌ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_I - a_I + 1 = 4
d_L - a_L + 1 = 5
d_R - a_R + 1 = 5
d_V - a_V + 1 = 3
d_P - a_P + 1 = 3
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_I, d_L, d_R, d_V, d_P) - min(a_I, a_L, a_R, a_V, a_P) + 1 = 16
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[2, 4] โฉ [a_L, d_L] โ โ
a_V โค 12 โค d_V
์งํญํธ์ด ์๋ ๋์:
(P โ L), (I โ V), (R โ P), (V โ R), (L โ V), (I โ R)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ๋ฐ๋ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋ฐ๋์์ ํ๋ฆฌ๋ก ๋นํ.
5-7์ผ์ฐจ: 3์ผ๊ฐ ํ๋ฆฌ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ํ๋ฆฌ์์ ๋ก๋ง๋ก ๋นํ.
7-11์ผ์ฐจ: 5์ผ๊ฐ ๋ก๋ง ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ๋ก๋ง์์ ๋ฒ ๋์ค์ผ๋ก ๋นํ.
11-13์ผ์ฐจ: 3์ผ๊ฐ ๋ฒ ๋์ค ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ๋ฒ ๋์ค์์ ์ธํฐ๋ผ์ผ๋ก ๋นํ.
13-16์ผ์ฐจ: 4์ผ๊ฐ ์ธํฐ๋ผ์ผ ๋ฐฉ๋ฌธ.
|
11
|
์ ๋ฝ
| 5
|
์ง์ ์์ฑ
|
์ด 15์ผ ๋์ ์ ๋ฝ 5๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ๋ก๋ง๋ฅผ 4์ผ๊ฐ ๋ฐฉ๋ฌธํ๊ณ ์ถ์ต๋๋ค. ํ๋ฆฌ์์ 5์ผ๊ฐ ์ฌํํ ์์ ์
๋๋ค. ์ฌํ 3-5์ผ์ฐจ์ ํ๋ฆฌ์์ ์งํ๋๋ ์ฌ๋ฆผํฝ์ ์ง๊ดํ ์์ ์
๋๋ค. ํ๋ํฌํธ๋ฅดํธ์์๋ 2์ผ๋ง ๋จธ๋ฌด๋ฅด๊ณ ์ ํฉ๋๋ค. ๋ฐ๋ฅด์
๋ก๋๋ฅผ 3์ผ๊ฐ ์ฌํํ ๊ฒ์
๋๋ค. ์ฌํ 7-8์ผ์ฐจ์ ๋ฐ๋ฅด์
๋ก๋์ ๊ฐ์ฐ๋ ํฌ์ด๋ฅผ ์์ฝํด๋์์ต๋๋ค. ํ์ด๋ธ๋ฒ ๋ฅดํฌ์์ 5์ผ์ ๋จธ๋ฌด๋ฅด๊ณ ์ถ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ํ๋ฆฌ์ ๋ฐ๋ฅด์
๋ก๋, ํ๋ฆฌ์ ๋ก๋ง, ํ๋ฆฌ์ ํ์ด๋ธ๋ฒ ๋ฅดํฌ. ๋ก๋ง์ ๋ฐ๋ฅด์
๋ก๋, ํ๋ํฌํธ๋ฅดํธ์ ํ๋ฆฌ, ํ์ด๋ธ๋ฒ ๋ฅดํฌ์ ๋ก๋ง.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 15์ผ ๋์ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ํ๋ํฌํธ๋ฅดํธ ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ํ๋ํฌํธ๋ฅดํธ์์ ํ๋ฆฌ๋ก ๋นํ.
2-6์ผ์ฐจ: 5์ผ๊ฐ ํ๋ฆฌ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ํ๋ฆฌ์์ ๋ฐ๋ฅด์
๋ก๋๋ก ๋นํ.
6-8์ผ์ฐจ: 3์ผ๊ฐ ๋ฐ๋ฅด์
๋ก๋ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ๋ฐ๋ฅด์
๋ก๋์์ ๋ก๋ง๋ก ๋นํ.
8-11์ผ์ฐจ: 4์ผ๊ฐ ๋ก๋ง ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ๋ก๋ง์์ ํ์ด๋ธ๋ฒ ๋ฅดํฌ๋ก ๋นํ.
11-15์ผ์ฐจ: 5์ผ๊ฐ ํ์ด๋ธ๋ฒ ๋ฅดํฌ ๋ฐฉ๋ฌธ.
|
You plan to visit 5 cities in Europe for a total of 15 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to visit Rome for 4 days. You plan to spend 5 days in Paris. You are planning to attend the Olympics in Paris on days 3 to 5 of your trip. You only want to spend 2 days in Frankfurt. You'll be traveling to Barcelona for 3 days. You've booked a Gaudi tour of Barcelona on days 7-8 of your trip. You'd like to spend 5 days in Heidelberg.
Here are the cities that have direct flights: Paris and Barcelona, Paris and Rome, Paris and Heidelberg. Rome and Barcelona, Frankfurt and Paris, Heidelberg and Rome.
Plan a trip to visit five cities in 15 days using direct flights.
|
Day 1-2: Visit Frankfurt for 2 days.
Day 2: Fly from Frankfurt to Paris.
Days 2-6: Visit Paris for 5 days.
Day 6: Fly from Paris to Barcelona.
Days 6-8: Visit Barcelona for 3 days.
Day 8: Fly from Barcelona to Rome.
Days 8-11: Visit Rome for 4 days.
Day 11: Fly from Rome to Heidelberg.
Days 11-15: Visit Heidelberg for 5 days.
|
๋ณ์ ์ ์:
R: ๋ก๋ง, P: ํ๋ฆฌ, F: ํ๋ํฌํธ๋ฅดํธ, B: ๋ฐ๋ฅด์
๋ก๋, H: ํ์ด๋ธ๋ฒ ๋ฅดํฌ
a_R: ๋ก๋ง ๋์ฐฉ์ผ, d_R: ๋ก๋ง ์ถ๋ฐ์ผ
a_P: ํ๋ฆฌ ๋์ฐฉ์ผ, d_P: ํ๋ฆฌ ์ถ๋ฐ์ผ
a_F: ํ๋ํฌํธ๋ฅดํธ ๋์ฐฉ์ผ, d_F: ํ๋ํฌํธ๋ฅดํธ ์ถ๋ฐ์ผ
a_B: ๋ฐ๋ฅด์
๋ก๋ ๋์ฐฉ์ผ, d_B: ๋ฐ๋ฅด์
๋ก๋ ์ถ๋ฐ์ผ
a_H: ํ์ด๋ธ๋ฒ ๋ฅดํฌ ๋์ฐฉ์ผ, d_H: ํ์ด๋ธ๋ฒ ๋ฅดํฌ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_R - a_R + 1 = 4
d_P - a_P + 1 = 5
d_F - a_F + 1 = 2
d_B - a_B + 1 = 3
d_H - a_H + 1 = 5
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_R, d_P, d_F, d_B, d_H) - min(a_R, a_P, a_F, a_B, a_H) + 1 = 15
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[3, 5] โ [a_P, d_P]
{7, 8} โ [a_B, d_B]
์งํญํธ์ด ์๋ ๋์:
(P โ B), (P โ R), (P โ H), (R โ B), (F โ P), (H โ R)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ํ๋ํฌํธ๋ฅดํธ ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ํ๋ํฌํธ๋ฅดํธ์์ ํ๋ฆฌ๋ก ๋นํ.
2-6์ผ์ฐจ: 5์ผ๊ฐ ํ๋ฆฌ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ํ๋ฆฌ์์ ๋ฐ๋ฅด์
๋ก๋๋ก ๋นํ.
6-8์ผ์ฐจ: 3์ผ๊ฐ ๋ฐ๋ฅด์
๋ก๋ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ๋ฐ๋ฅด์
๋ก๋์์ ๋ก๋ง๋ก ๋นํ.
8-11์ผ์ฐจ: 4์ผ๊ฐ ๋ก๋ง ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ๋ก๋ง์์ ํ์ด๋ธ๋ฒ ๋ฅดํฌ๋ก ๋นํ.
11-15์ผ์ฐจ: 5์ผ๊ฐ ํ์ด๋ธ๋ฒ ๋ฅดํฌ ๋ฐฉ๋ฌธ.
|
12
|
์ ๋ฝ
| 5
|
์ง์ ์์ฑ
|
์ด 14์ผ ๋์ ์ ๋ฝ 5๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ํฌ์ฑํค๋ฅผ 4์ผ ๋์ ๋ฐฉ๋ฌธํ ์์ ์
๋๋ค. ์ฌํ 11-13์ผ์ฐจ์ ํฌ์ฑํค์์ ์ฝ์์ด ์์ต๋๋ค. ํ๋ฆฐ์์ 3์ผ์ ๋จธ๋ฌด๋ฅผ ๊ฒ์
๋๋ค. ๋ฒ ๋ฅด๊ฒ์์๋ 3์ผ์ ๋จธ๋ฌด๋ฅด๋ ค๊ณ ํฉ๋๋ค. 3์ผ์์ 5์ผ ์ฌ์ด์ ๋ฒ ๋ฅด๊ฒ์ ์๋ ์์๋ฅผ ๋ฏธ๋ฆฌ ์์ฝํด๋์์ต๋๋ค. ์คํกํ๋กฌ์์๋ 5์ผ ๋์ ๋จธ๋ฌด๋ฅด๊ณ ์ถ์ต๋๋ค. ์ฝํํ๊ฒ์ 3์ผ ๋์ ์ฌํํ ๊ฒ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ํฌ์ฑํค์ ํ๋ฆฐ, ํฌ์ฑํค์ ๋ฒ ๋ฅด๊ฒ, ์คํกํ๋กฌ๊ณผ ๋ฒ ๋ฅด๊ฒ, ์คํกํ๋กฌ๊ณผ ์ฝํํ๊ฒ, ์คํกํ๋กฌ๊ณผ ํ๋ฆฐ, ์ฝํํ๊ฒ๊ณผ ๋ฒ ๋ฅด๊ฒ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 14์ผ ๋์ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ์ฝํํ๊ฒ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ์ฝํํ๊ฒ์์ ๋ฒ ๋ฅด๊ฒ์ผ๋ก ๋นํ.
3-5์ผ์ฐจ: 3์ผ๊ฐ ๋ฒ ๋ฅด๊ฒ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋ฒ ๋ฅด๊ฒ์์ ์คํกํ๋กฌ์ผ๋ก ๋นํ.
5-9์ผ์ฐจ: 5์ผ๊ฐ ์คํกํ๋กฌ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ์คํกํ๋กฌ์์ ํ๋ฆฐ์ผ๋ก ๋นํ.
9-11์ผ์ฐจ: 3์ผ๊ฐ ํ๋ฆฐ ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ํ๋ฆฐ์์ ํฌ์ฑํค๋ก ๋นํ.
11-14์ผ์ฐจ: 4์ผ๊ฐ ํฌ์ฑํค ๋ฐฉ๋ฌธ.
|
You plan to visit 5 cities in Europe for a total of 14 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You plan to visit Helsinki for 4 days. You have an appointment in Helsinki on days 11-13 of your trip. You'll spend 3 days in Tallinn. You'll also spend 3 days in Bergen. You've already booked a place to stay in Bergen between days 3 and 5. In Stockholm, you want to stay for five days. You will be traveling to Copenhagen for 3 days.
Here are the cities that have direct flights: Helsinki and Tallinn, Helsinki and Bergen, Stockholm and Bergen, Stockholm and Copenhagen, Stockholm and Tallinn, Copenhagen and Bergen.
Plan a trip to visit five cities in 14 days with direct flights.
|
Days 1-3: Visit Copenhagen for 3 days.
Day 3: Fly from Copenhagen to Bergen.
Days 3-5: Visit Bergen for 3 days.
Day 5: Fly from Bergen to Stockholm.
Days 5-9: Visit Stockholm for 5 days.
Day 9: Fly from Stockholm to Tallinn.
Days 9-11: Visit Tallinn for 3 days.
Day 11: Fly from Tallinn to Helsinki.
Days 11-14: Visit Helsinki for 4 days.
|
๋ณ์ ์ ์:
H: ํฌ์ฑํค, T: ํ๋ฆฐ, B: ๋ฒ ๋ฅด๊ฒ, S: ์คํกํ๋ฆ, C: ์ฝํํ๊ฒ
a_H: ํฌ์ฑํค ๋์ฐฉ์ผ, d_H: ํฌ์ฑํค ์ถ๋ฐ์ผ
a_T: ํ๋ฆฐ ๋์ฐฉ์ผ, d_T: ํ๋ฆฐ ์ถ๋ฐ์ผ
a_B: ๋ฒ ๋ฅด๊ฒ ๋์ฐฉ์ผ, d_B: ๋ฒ ๋ฅด๊ฒ ์ถ๋ฐ์ผ
a_S: ์คํกํ๋ฆ ๋์ฐฉ์ผ, d_S: ์คํกํ๋ฆ ์ถ๋ฐ์ผ
a_C: ์ฝํํ๊ฒ ๋์ฐฉ์ผ, d_C: ์ฝํํ๊ฒ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_H - a_H + 1 = 4
d_T - a_T + 1 = 3
d_B - a_B + 1 = 3
d_S - a_S + 1 = 5
d_C - a_C + 1 = 3
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_H, d_T, d_B, d_S, d_C) - min(a_H, a_T, a_B, a_S, a_C) + 1 = 14
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[11, 13] โฉ [a_H, d_H] โ โ
[3, 5] โฉ [a_B, d_B] โ โ
์งํญํธ์ด ์๋ ๋์:
(H โ T), (H โ B), (S โ B), (S โ C), (S โ T), (C โ B)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ์ฝํํ๊ฒ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ์ฝํํ๊ฒ์์ ๋ฒ ๋ฅด๊ฒ์ผ๋ก ๋นํ.
3-5์ผ์ฐจ: 3์ผ๊ฐ ๋ฒ ๋ฅด๊ฒ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋ฒ ๋ฅด๊ฒ์์ ์คํกํ๋กฌ์ผ๋ก ๋นํ.
5-9์ผ์ฐจ: 5์ผ๊ฐ ์คํกํ๋กฌ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ์คํกํ๋กฌ์์ ํ๋ฆฐ์ผ๋ก ๋นํ.
9-11์ผ์ฐจ: 3์ผ๊ฐ ํ๋ฆฐ ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ํ๋ฆฐ์์ ํฌ์ฑํค๋ก ๋นํ.
11-14์ผ์ฐจ: 4์ผ๊ฐ ํฌ์ฑํค ๋ฐฉ๋ฌธ.
|
13
|
์ ๋ฝ
| 6
|
๋
ผ๋ฌธ ๋ฒ์ญ
|
์ด 13์ผ ๋์ ์ ๋ฝ 6๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ๋๋ธ๋ฆฐ์์ 3์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. 7์ผ์งธ๋ถํฐ 9์ผ์งธ๊น์ง ๋๋ธ๋ฆฐ์์ ์น๊ตฌ๋ฅผ ๋ง๋ ํจ๊ป ์ฌํํ๊ณ ์ถ์ต๋๋ค. 2์ผ ๋์ ๋ง๋๋ฆฌ๋๋ฅผ ๋ฐฉ๋ฌธํ๊ณ ์ถ์ต๋๋ค. 2์ผ์งธ์ 3์ผ์งธ ์ฌ์ด์ ๋ง๋๋ฆฌ๋์ ์๋ ์น์ฒ์ง์ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. 3์ผ๊ฐ ์ค์ฌ๋ก์ ๋จธ๋ฌผ ๊ณํ์
๋๋ค. 2์ผ ๋์ ๋ฐ๋์ ๋ฐฉ๋ฌธํ๊ณ ์ถ์ต๋๋ค. ๋น๋์ฐ์ค์์ 3์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. 5์ผ ๋์ ๋ฒ ๋ฅผ๋ฆฐ์ ๋จธ๋ฌผ ๊ณํ์
๋๋ค. 3์ผ์์ 7์ผ ์ฌ์ด์ ๋ฒ ๋ฅผ๋ฆฐ์์ ๊ฒฐํผ์์ ์ฐธ์ํ ์์ ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ฐ๋๊ณผ ๋ง๋๋ฆฌ๋, ์ค์ฌ๋ก์ ๋น๋์ฐ์ค, ๋ฒ ๋ฅผ๋ฆฐ๊ณผ ๋น๋์ฐ์ค, ๋ง๋๋ฆฌ๋์ ์ค์ฌ๋ก, ๋ง๋๋ฆฌ๋์ ๋๋ธ๋ฆฐ, ๋ฐ๋๊ณผ ์ค์ฌ๋ก, ๋ง๋๋ฆฌ๋์ ๋ฒ ๋ฅผ๋ฆฐ, ๋ฒ ๋ฅผ๋ฆฐ๊ณผ ์ค์ฌ๋ก, ๋๋ธ๋ฆฐ๊ณผ ์ค์ฌ๋ก, ๋ฐ๋๊ณผ ๋๋ธ๋ฆฐ, ๋ฐ๋๊ณผ ๋ฒ ๋ฅผ๋ฆฐ, ๋ฒ ๋ฅผ๋ฆฐ๊ณผ ๋๋ธ๋ฆฐ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 13์ผ ๋์ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ๋ฐ๋ ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ๋ฐ๋์์ ๋ง๋๋ฆฌ๋๋ก ๋นํ.
2-3์ผ์ฐจ: 2์ผ๊ฐ ๋ง๋๋ฆฌ๋ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋ง๋๋ฆฌ๋์์ ๋ฒ ๋ฅผ๋ฆฐ์ผ๋ก ๋นํ.
3-7์ผ์ฐจ: 5์ผ๊ฐ ๋ฒ ๋ฅผ๋ฆฐ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ๋ฒ ๋ฅผ๋ฆฐ์์ ๋๋ธ๋ฆฐ์ผ๋ก ๋นํ.
7-9์ผ์ฐจ: 3์ผ๊ฐ ๋๋ธ๋ฆฐ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ๋๋ธ๋ฆฐ์์ ์ค์ฌ๋ก๋ก ๋นํ.
9-11์ผ์ฐจ: 3์ผ๊ฐ ์ค์ฌ๋ก ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ์ค์ฌ๋ก์์ ๋น๋์ฐ์ค๋ก ๋นํ.
11-13์ผ์ฐจ: 3์ผ๊ฐ ๋น๋์ฐ์ค ๋ฐฉ๋ฌธ.
|
You plan to visit 6 cities in Europe for a total of 13 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to spend 3 days in Dublin. You want to meet a friend in Dublin on days 7 through 9 and travel with him. You want to visit Madrid for 2 days. You plan to visit your relatives in Madrid between days 2 and 3. You plan to stay in Oslo for 3 days. You want to visit London for 2 days. You want to spend 3 days in Vilnius. You plan to stay in Berlin for 5 days. You plan to attend a wedding in Berlin between the 3rd and 7th.
Here are the cities that have direct flights: London and Madrid, Oslo and Vilnius, Berlin and Vilnius, Madrid and Oslo, Madrid and Dublin, London and Oslo, Madrid and Berlin, Berlin and Oslo, Dublin and Oslo, London and Dublin, London and Berlin, Berlin and Dublin.
Plan a trip to visit six cities in 13 days with direct flights.
|
Days 1-2: Visit London for 2 days.
Day 2: Fly from London to Madrid.
Days 2-3: Visit Madrid for 2 days.
Day 3: Fly from Madrid to Berlin.
Days 3-7: Visit Berlin for 5 days.
Day 7: Fly from Berlin to Dublin.
Days 7-9: Visit Dublin for 3 days.
Day 9: Fly from Dublin to Oslo.
Days 9-11: Visit Oslo for 3 days.
Day 11: Fly from Oslo to Vilnius.
Days 11-13: Visit Vilnius for 3 days.
|
๋ณ์ ์ ์:
D: ๋๋ธ๋ฆฐ, M: ๋ง๋๋ฆฌ๋, O: ์ค์ฌ๋ก, L: ๋ฐ๋, V: ๋น๋์ฐ์ค, B: ๋ฒ ๋ฅผ๋ฆฐ
a_D: ๋๋ธ๋ฆฐ ๋์ฐฉ์ผ, d_D: ๋๋ธ๋ฆฐ ์ถ๋ฐ์ผ
a_M: ๋ง๋๋ฆฌ๋ ๋์ฐฉ์ผ, d_M: ๋ง๋๋ฆฌ๋ ์ถ๋ฐ์ผ
a_O: ์ค์ฌ๋ก ๋์ฐฉ์ผ, d_O: ์ค์ฌ๋ก ์ถ๋ฐ์ผ
a_L: ๋ฐ๋ ๋์ฐฉ์ผ, d_L: ๋ฐ๋ ์ถ๋ฐ์ผ
a_V: ๋น๋์ฐ์ค ๋์ฐฉ์ผ, d_V: ๋น๋์ฐ์ค ์ถ๋ฐ์ผ
a_B: ๋ฒ ๋ฅผ๋ฆฐ ๋์ฐฉ์ผ, d_B: ๋ฒ ๋ฅผ๋ฆฐ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_D - a_D + 1 = 3
d_M - a_M + 1 = 2
d_O - a_O + 1 = 3
d_L - a_L + 1 = 2
d_V - a_V + 1 = 3
d_B - a_B + 1 = 5
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_D, d_M, d_O, d_L, d_V, d_B) - min(a_D, a_M, a_O, a_L, a_V, a_B) + 1 = 13
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
{7, 8, 9} โ [a_D, d_D]
{2, 3} โฉ [a_M, d_M] โ โ
[3, 7] โฉ [a_B, d_B] โ โ
์งํญํธ์ด ์๋ ๋์:
(L โ M), (O โ V), (B โ V), (M โ O), (M โ D), (L โ O), (M โ B), (B โ O), (D โ O), (L โ D), (L โ B), (B โ D)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ๋ฐ๋ ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ๋ฐ๋์์ ๋ง๋๋ฆฌ๋๋ก ๋นํ.
2-3์ผ์ฐจ: 2์ผ๊ฐ ๋ง๋๋ฆฌ๋ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋ง๋๋ฆฌ๋์์ ๋ฒ ๋ฅผ๋ฆฐ์ผ๋ก ๋นํ.
3-7์ผ์ฐจ: 5์ผ๊ฐ ๋ฒ ๋ฅผ๋ฆฐ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ๋ฒ ๋ฅผ๋ฆฐ์์ ๋๋ธ๋ฆฐ์ผ๋ก ๋นํ.
7-9์ผ์ฐจ: 3์ผ๊ฐ ๋๋ธ๋ฆฐ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ๋๋ธ๋ฆฐ์์ ์ค์ฌ๋ก๋ก ๋นํ.
9-11์ผ์ฐจ: 3์ผ๊ฐ ์ค์ฌ๋ก ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ์ค์ฌ๋ก์์ ๋น๋์ฐ์ค๋ก ๋นํ.
11-13์ผ์ฐจ: 3์ผ๊ฐ ๋น๋์ฐ์ค ๋ฐฉ๋ฌธ.
|
14
|
์ ๋ฝ
| 6
|
๋
ผ๋ฌธ ๋ฒ์ญ
|
์ด 17์ผ ๋์ ์ ๋ฝ 6๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ๋งจ์ฒด์คํฐ์์ 4์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. ํผ๋ ์ฒด์์ 5์ผ๊ฐ ๋จธ๋ฌผ ๊ณํ์
๋๋ค. ์ ๋ค๋ฐ์์ 3์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. 1์ผ์ฐจ๋ถํฐ 3์ผ์ฐจ๊น์ง ์ ๋ค๋ฐ์์ ๊ฒฐํผ์์ ์ฐธ์ํ ์์ ์
๋๋ค. ์ธ๋น์ผ์์ 3์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. 7์ผ์งธ์ 9์ผ์งธ์๋ ์ธ๋น์ผ์์ ์ด๋ฆฌ๋ ์ปจํผ๋ฐ์ค์ ์ฐธ์ํด์ผ ํฉ๋๋ค. 2์ผ ๋์ ํ๋ผํ๋ฅผ ๋ฐฉ๋ฌธํ๊ณ ์ถ์ต๋๋ค. 5์ผ ๋์ ๋ฐ๋ ์์์์ ๋จธ๋ฌผ ๊ณํ์
๋๋ค. 3์ผ์ฐจ๋ถํฐ 7์ผ์ฐจ๊น์ง ๋ฐ๋ ์์์์ ์ฐธ์ํ๊ณ ์ถ์ ์ฐ๋ก ์ผ๊ฐ ์์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋งจ์ฒด์คํฐ์ ํ๋ผํ, ์ธ๋น์ผ์ ๋งจ์ฒด์คํฐ, ์ ๋ค๋ฐ์ ๋งจ์ฒด์คํฐ, ๋ฐ๋ ์์์ ์ธ๋น์ผ, ์ ๋ค๋ฐ์ ๋ฐ๋ ์์, ๋ฐ๋ ์์์ ํ๋ผํ, ํ๋ผํ์ ํผ๋ ์ฒด, ์ ๋ค๋ฐ์ ํ๋ผํ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 17์ผ ๋์ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ์ ๋ค๋ฐ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ์ ๋ค๋ฐ์์ ๋ฐ๋ ์์๋ก ๋นํ.
3-7์ผ์ฐจ: 5์ผ๊ฐ ๋ฐ๋ ์์ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ๋ฐ๋ ์์์์ ์ธ๋น์ผ์ผ๋ก ๋นํ.
7-9์ผ์ฐจ: 3์ผ๊ฐ ์ธ๋น์ผ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ์ธ๋น์ผ์์ ๋งจ์ฒด์คํฐ๋ก ๋นํ.
9-12์ผ์ฐจ: 4์ผ๊ฐ ๋งจ์ฒด์คํฐ ๋ฐฉ๋ฌธ.
12์ผ์ฐจ: ๋งจ์ฒด์คํฐ์์ ํ๋ผํ๋ก ๋นํ.
12-13์ผ์ฐจ: 2์ผ๊ฐ ํ๋ผํ ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ํ๋ผํ์์ ํผ๋ ์ฒด๋ก ๋นํ.
13-17์ผ์ฐจ: 5์ผ๊ฐ ํผ๋ ์ฒด ๋ฐฉ๋ฌธ.
|
You plan to visit 6 cities in Europe for a total of 17 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to spend 4 days in Manchester. You plan to spend 5 days in Florence. You want to spend 3 days in Geneva. You are planning to attend a wedding in Geneva from day 1 to day 3. You want to spend 3 days in Seville. On days 7 and 9, You need to attend a conference in Seville. You want to visit Prague for 2 days. You plan to spend 5 days in Valencia. From day 3 to day 7, there is an annual show in Valencia that you would like to attend..
Here are the cities that have direct flights: Manchester and Prague, Seville and Manchester, Geneva and Manchester, Valencia and Seville, Geneva and Valencia, Valencia and Prague, Prague and Florence, Geneva and Prague.
Plan a trip to visit six cities in 17 days with direct flights.
|
Days 1-3: Visit Geneva for 3 days.
Day 3: Fly from Geneva to Valencia.
Days 3-7: Visit Valencia for 5 days.
Day 7: Fly from Valencia to Seville.
Days 7-9: Visit Seville for 3 days.
Day 9: Fly from Seville to Manchester.
Days 9-12: Visit Manchester for 4 days.
Day 12: Fly from Manchester to Prague.
Days 12-13: Visit Prague for 2 days.
Day 13: Fly from Prague to Florence.
Days 13-17: Visit Florence for 5 days.
|
๋ณ์ ์ ์:
M: ๋งจ์ฒด์คํฐ, F: ํผ๋ ์ฒด, G: ์ ๋ค๋ฐ, S: ์ธ๋น์ผ, P: ํ๋ผํ, V: ๋ฐ๋ ์์
a_M: ๋งจ์ฒด์คํฐ ๋์ฐฉ์ผ, d_M: ๋งจ์ฒด์คํฐ ์ถ๋ฐ์ผ
a_F: ํผ๋ ์ฒด ๋์ฐฉ์ผ, d_F: ํผ๋ ์ฒด ์ถ๋ฐ์ผ
a_G: ์ ๋ค๋ฐ ๋์ฐฉ์ผ, d_G: ์ ๋ค๋ฐ ์ถ๋ฐ์ผ
a_S: ์ธ๋น์ผ ๋์ฐฉ์ผ, d_S: ์ธ๋น์ผ ์ถ๋ฐ์ผ
a_P: ํ๋ผํ ๋์ฐฉ์ผ, d_P: ํ๋ผํ ์ถ๋ฐ์ผ
a_V: ๋ฐ๋ ์์ ๋์ฐฉ์ผ, d_V: ๋ฐ๋ ์์ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_M - a_M + 1 = 4
d_F - a_F + 1 = 5
d_G - a_G + 1 = 3
d_S - a_S + 1 = 3
d_P - a_P + 1 = 2
d_V - a_V + 1 = 5
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_M, d_F, d_G, d_S, d_P, d_V) - min(a_M, a_F, a_G, a_S, a_P, a_V) + 1 = 17
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
a_G = 1
{7, 9} โ [a_S, d_S]
[3, 7] โฉ [a_V, d_V] โ โ
์งํญํธ์ด ์๋ ๋์:
(M โ P), (S โ M), (G โ M), (V โ S), (G โ V), (V โ P), (P โ F), (G โ P)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ์ ๋ค๋ฐ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ์ ๋ค๋ฐ์์ ๋ฐ๋ ์์๋ก ๋นํ.
3-7์ผ์ฐจ: 5์ผ๊ฐ ๋ฐ๋ ์์ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ๋ฐ๋ ์์์์ ์ธ๋น์ผ์ผ๋ก ๋นํ.
7-9์ผ์ฐจ: 3์ผ๊ฐ ์ธ๋น์ผ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ์ธ๋น์ผ์์ ๋งจ์ฒด์คํฐ๋ก ๋นํ.
9-12์ผ์ฐจ: 4์ผ๊ฐ ๋งจ์ฒด์คํฐ ๋ฐฉ๋ฌธ.
12์ผ์ฐจ: ๋งจ์ฒด์คํฐ์์ ํ๋ผํ๋ก ๋นํ.
12-13์ผ์ฐจ: 2์ผ๊ฐ ํ๋ผํ ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ํ๋ผํ์์ ํผ๋ ์ฒด๋ก ๋นํ.
13-17์ผ์ฐจ: 5์ผ๊ฐ ํผ๋ ์ฒด ๋ฐฉ๋ฌธ.
|
15
|
์ ๋ฝ
| 6
|
์ง์ ์์ฑ
|
์ด 21์ผ ๋์ ์ ๋ฝ 6๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ๋ฃจ๋ธ๋ผ๋์์๋ 3์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. ํ๋ผํ์์ 5์ผ๊ฐ ๋จธ๋ฌด๋ฅผ ๊ฒ์
๋๋ค. ํ๋ผํ์์ 17-18์ผ ์ฌ์ด์ ์งํ๋๋ ํํ์ ์ฐธ์ํ ๊ฒ์
๋๋ค. ๋ฎํจ์์ 4์ผ๊ฐ ๋จธ๋ฌด๋ฅผ ์์ ์
๋๋ค. 3์ผ ๋์ ํ๋ฆฌํธ๋น์ฒด์์ ์ฌํ์ ํ ๊ฒ์
๋๋ค. ์์ธ ๋ถ๋ฅดํฌ์์ 5์ผ ๋์ ์ฌํ์ ํ๊ณ ์ถ์ต๋๋ค. ๋ถ๋คํ์คํธ์์ 6์ผ๊ฐ ๋จธ๋ฌด๋ฅผ ๊ฒ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ฃจ๋ธ๋ผ๋์ ์์ธ ๋ถ๋ฅดํฌ, ํ๋ผํ์ ๋ถ๋คํ์คํธ, ๋ฎํจ๊ณผ ์์ธ ๋ถ๋ฅดํฌ, ํ๋ฆฌํธ๋น์ฒด์ ๋ถ๋คํ์คํธ, ํ๋ฆฌํธ๋น์ฒด์ ๋ฃจ๋ธ๋ผ๋.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 21์ผ ๋์ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ๋ฎํจ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ๋ฎํจ์์ ์์ธ ๋ถ๋ฅดํฌ๋ก ๋นํ.
4-8์ผ์ฐจ: 5์ผ๊ฐ ์์ธ ๋ถ๋ฅดํฌ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ์์ธ ๋ถ๋ฅดํฌ์์ ๋ฃจ๋ธ๋ผ๋์ผ๋ก ๋นํ.
8-10์ผ์ฐจ: 3์ผ๊ฐ ๋ฃจ๋ธ๋ผ๋ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ๋ฃจ๋ธ๋ผ๋์์ ํ๋ฆฌํธ๋น์ฒด์ผ๋ก ๋นํ.
10-12์ผ์ฐจ: 3์ผ๊ฐ ํ๋ฆฌํธ๋น์ฒด ๋ฐฉ๋ฌธ.
12์ผ์ฐจ: ํ๋ฆฌํธ๋น์ฒด์์ ๋ถ๋คํ์คํธ๋ก ๋นํ.
12-17์ผ์ฐจ: 6์ผ๊ฐ ๋ถ๋คํ์คํธ ๋ฐฉ๋ฌธ.
17์ผ์ฐจ: ๋ถ๋คํ์คํธ์์ ํ๋ผํ๋ก ๋นํ.
17-21์ผ์ฐจ: 5์ผ๊ฐ ํ๋ผํ ๋ฐฉ๋ฌธ.
|
You plan to visit 6 cities in Europe for a total of 21 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'd like to spend 3 days in Ljubljana. You'll be in Prague for 5 days. You'll be attending a conference in Prague between the 17th and 18th. You'll be in Munich for 4 days. You'll be traveling in Plitvice for 3 days. You'd like to travel in Salzburg for 5 days. You will be traveling from Budapest for 6 days.
Here are the cities that have direct flights: Ljubljana and Salzburg, Prague and Budapest, Munich and Salzburg, Plitvice and Budapest, Plitvice and Ljubljana.
Plan your trip to visit six cities in 21 days with direct flights.
|
Days 1-4: Visit Munich for 4 days.
Day 4: Fly from Munich to Salzburg.
Days 4-8: Visit Salzburg for 5 days.
Day 8: Fly from Salzburg to Ljubljana.
Days 8-10: Visit Ljubljana for 3 days.
Day 10: Fly from Ljubljana to Plitvice.
Days 10-12: Visit Plitvice for 3 days.
Day 12: Fly from Plitvice to Budapest.
Days 12-17: Visit Budapest for 6 days.
Day 17: Fly from Budapest to Prague.
Days 17-21: Visit Prague for 5 days.
|
๋ณ์ ์ ์:
L: ๋ฃจ๋ธ๋ผ๋, P: ํ๋ผํ, M: ๋ฎํจ, F: ํ๋ฆฌํธ๋น์ฒด, S: ์์ธ ๋ถ๋ฅดํฌ, B: ๋ถ๋คํ์คํธ
a_L: ๋ฃจ๋ธ๋ผ๋ ๋์ฐฉ์ผ, d_L: ๋ฃจ๋ธ๋ผ๋ ์ถ๋ฐ์ผ
a_P: ํ๋ผํ ๋์ฐฉ์ผ, d_P: ํ๋ผํ ์ถ๋ฐ์ผ
a_M: ๋ฎํจ ๋์ฐฉ์ผ, d_M: ๋ฎํจ ์ถ๋ฐ์ผ
a_F: ํ๋ฆฌํธ๋น์ฒด ๋์ฐฉ์ผ, d_F: ํ๋ฆฌํธ๋น์ฒด ์ถ๋ฐ์ผ
a_S: ์์ธ ๋ถ๋ฅดํฌ ๋์ฐฉ์ผ, d_S: ์์ธ ๋ถ๋ฅดํฌ ์ถ๋ฐ์ผ
a_B: ๋ถ๋คํ์คํธ ๋์ฐฉ์ผ, d_B: ๋ถ๋คํ์คํธ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_L - a_L + 1 = 3
d_P - a_P + 1 = 5
d_M - a_M + 1 = 4
d_F - a_F + 1 = 3
d_S - a_S + 1 = 5
d_B - a_B + 1 = 6
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_L, d_P, d_M, d_F, d_S, d_B) - min(a_L, a_P, a_M, a_F, a_S, a_B) + 1 = 21
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[17, 18] โฉ [a_P, d_P] โ โ
์งํญํธ์ด ์๋ ๋์:
(L โ S), (P โ B), (M โ S), (F โ B), (F โ L)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ๋ฎํจ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ๋ฎํจ์์ ์์ธ ๋ถ๋ฅดํฌ๋ก ๋นํ.
4-8์ผ์ฐจ: 5์ผ๊ฐ ์์ธ ๋ถ๋ฅดํฌ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ์์ธ ๋ถ๋ฅดํฌ์์ ๋ฃจ๋ธ๋ผ๋์ผ๋ก ๋นํ.
8-10์ผ์ฐจ: 3์ผ๊ฐ ๋ฃจ๋ธ๋ผ๋ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ๋ฃจ๋ธ๋ผ๋์์ ํ๋ฆฌํธ๋น์ฒด์ผ๋ก ๋นํ.
10-12์ผ์ฐจ: 3์ผ๊ฐ ํ๋ฆฌํธ๋น์ฒด ๋ฐฉ๋ฌธ.
12์ผ์ฐจ: ํ๋ฆฌํธ๋น์ฒด์์ ๋ถ๋คํ์คํธ๋ก ๋นํ.
12-17์ผ์ฐจ: 6์ผ๊ฐ ๋ถ๋คํ์คํธ ๋ฐฉ๋ฌธ.
17์ผ์ฐจ: ๋ถ๋คํ์คํธ์์ ํ๋ผํ๋ก ๋นํ.
17-21์ผ์ฐจ: 5์ผ๊ฐ ํ๋ผํ ๋ฐฉ๋ฌธ.
|
16
|
์ ๋ฝ
| 6
|
์ง์ ์์ฑ
|
์ด 18์ผ ๋์ ์ ๋ฝ 6๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์์คํ
๋ฅด๋ด์์ 3์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. ๋ฒ ๋ฅผ๋ฆฐ์์ 4์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. 11์ผ์์ 12์ผ ์ฌ์ด์ ๋ฒ ๋ฅผ๋ฆฐ์ ์๋ ์ธ๋ ์ง์ ๋ค๋ฅผ ๊ฒ์
๋๋ค. 7์ผ๊ฐ ์ค์ฌ๋ก๋ฅผ ์ฌํํ ๊ฒ์
๋๋ค. ๋ฐ๋์์ 4์ผ ๋์ ๋จธ๋ฌด๋ฅผ ์์ ์
๋๋ค. ์ฌํ 17์ผ์ฐจ์ ๋ฐ๋์์ ๋ฎค์ง์ปฌ์ ๋ณผ ๊ฒ์
๋๋ค. ์คํกํ๋กฌ์์ 3์ผ์ ๋ณด๋ผ ๊ฒ์
๋๋ค. ์ฌํ์ ์์์ ์คํกํ๋กฌ์ด์์ผ๋ฉด ์ข๊ฒ ์ต๋๋ค. ์ฝํํ๊ฒ์์๋ 2์ผ๊ฐ ๋จธ๋ฌด๋ฅด๋ ค๊ณ ํฉ๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ฐ๋๊ณผ ์์คํ
๋ฅด๋ด, ๋ฐ๋๊ณผ ์ฝํํ๊ฒ, ์ค์ฌ๋ก์ ์คํกํ๋กฌ, ๋ฒ ๋ฅผ๋ฆฐ๊ณผ ์ฝํํ๊ฒ, ๋ฒ ๋ฅผ๋ฆฐ๊ณผ ์คํกํ๋กฌ, ์์คํ
๋ฅด๋ด๊ณผ ๋ฒ ๋ฅผ๋ฆฐ, ์ฝํํ๊ฒ๊ณผ ์ค์ฌ๋ก, ์ฝํํ๊ฒ๊ณผ ์คํกํ๋กฌ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 18์ผ ๋์ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ์คํกํ๋กฌ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ์คํกํ๋กฌ์์ ์ค์ฌ๋ก๋ก ๋นํ.
3-9์ผ์ฐจ: 7์ผ๊ฐ ์ค์ฌ๋ก ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ์ค์ฌ๋ก์์ ์ฝํํ๊ฒ์ผ๋ก ๋นํ.
9-10์ผ์ฐจ: 2์ผ๊ฐ ์ฝํํ๊ฒ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ์ฝํํ๊ฒ์์ ๋ฒ ๋ฅผ๋ฆฐ์ผ๋ก ๋นํ.
10-13์ผ์ฐจ: 4์ผ๊ฐ ๋ฒ ๋ฅผ๋ฆฐ ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ๋ฒ ๋ฅผ๋ฆฐ์์ ์์คํ
๋ฅด๋ด์ผ๋ก ๋นํ.
13-15์ผ์ฐจ: 3์ผ๊ฐ ์์คํ
๋ฅด๋ด ๋ฐฉ๋ฌธ.
15์ผ์ฐจ: ์์คํ
๋ฅด๋ด์์ ๋ฐ๋์ผ๋ก ๋นํ.
15-18์ผ์ฐจ: 4์ผ๊ฐ ๋ฐ๋ ๋ฐฉ๋ฌธ.
|
You plan to visit 6 cities in Europe for a total of 18 days.You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to spend 3 days in Amsterdam. You want to spend 4 days in Berlin. You will be stopping by your sister's house in Berlin between the 11th and the 12th. You'll travel to Oslo for 7 days. You'll spend 4 days in London. On day 17 of your trip, you will watch a musical in London. You will spend 3 days in Stockholm. You want to start your trip in Stockholm. You will spend 2 days in Copenhagen.
Here are the cities that have direct flights: London and Amsterdam, London and Copenhagen, Oslo and Stockholm, Berlin and Copenhagen, Berlin and Stockholm, Amsterdam and Berlin, Copenhagen and Oslo, Copenhagen and Stockholm.
Plan a trip to visit six cities in 18 days with direct flights.
|
Days 1-3: Visit Stockholm for 3 days.
Day 3: Fly from Stockholm to Oslo.
Days 3-9: Visit Oslo for 7 days.
Day 9: Fly from Oslo to Copenhagen.
Days 9-10: Visit Copenhagen for 2 days.
Day 10: Fly from Copenhagen to Berlin.
Days 10-13: Visit Berlin for 4 days.
Day 13: Fly from Berlin to Amsterdam.
Days 13-15: Visit Amsterdam for 3 days.
Day 15: Fly from Amsterdam to London.
Days 15-18: Visit London for 4 days.
|
๋ณ์ ์ ์:
A: ์์คํ
๋ฅด๋ด, B: ๋ฒ ๋ฅผ๋ฆฐ, O: ์ค์ฌ๋ก, L: ๋ฐ๋, S: ์คํกํ๋กฌ, C: ์ฝํํ๊ฒ
a_A: ์์คํ
๋ฅด๋ด ๋์ฐฉ์ผ, d_A: ์์คํ
๋ฅด๋ด ์ถ๋ฐ์ผ
a_B: ๋ฒ ๋ฅผ๋ฆฐ ๋์ฐฉ์ผ, d_B: ๋ฒ ๋ฅผ๋ฆฐ ์ถ๋ฐ์ผ
a_O: ์ค์ฌ๋ก ๋์ฐฉ์ผ, d_O: ์ค์ฌ๋ก ์ถ๋ฐ์ผ
a_L: ๋ฐ๋ ๋์ฐฉ์ผ, d_L: ๋ฐ๋ ์ถ๋ฐ์ผ
a_S: ์คํกํ๋กฌ ๋์ฐฉ์ผ, d_S: ์คํกํ๋กฌ ์ถ๋ฐ์ผ
a_C: ์ฝํํ๊ฒ ๋์ฐฉ์ผ, d_C: ์ฝํํ๊ฒ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_A - a_A + 1 = 3
d_B - a_B + 1 = 4
d_O - a_O + 1 = 7
d_L - a_L + 1 = 4
d_S - a_S + 1 = 3
d_C - a_C + 1 = 2
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_A, d_B, d_O, d_L, d_S, d_C) - min(a_A, a_B, a_O, a_L, a_S, a_C) + 1 = 18
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[11, 12] โฉ [a_B, d_B] โ โ
a_L โค 17 โค d_L
a_S = 1
์งํญํธ์ด ์๋ ๋์:
(L โ A), (L โ C), (O โ S), (B โ C), (B โ S), (A โ B), (C โ O), (C โ S)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ์คํกํ๋กฌ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ์คํกํ๋กฌ์์ ์ค์ฌ๋ก๋ก ๋นํ.
3-9์ผ์ฐจ: 7์ผ๊ฐ ์ค์ฌ๋ก ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ์ค์ฌ๋ก์์ ์ฝํํ๊ฒ์ผ๋ก ๋นํ.
9-10์ผ์ฐจ: 2์ผ๊ฐ ์ฝํํ๊ฒ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ์ฝํํ๊ฒ์์ ๋ฒ ๋ฅผ๋ฆฐ์ผ๋ก ๋นํ.
10-13์ผ์ฐจ: 4์ผ๊ฐ ๋ฒ ๋ฅผ๋ฆฐ ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ๋ฒ ๋ฅผ๋ฆฐ์์ ์์คํ
๋ฅด๋ด์ผ๋ก ๋นํ.
13-15์ผ์ฐจ: 3์ผ๊ฐ ์์คํ
๋ฅด๋ด ๋ฐฉ๋ฌธ.
15์ผ์ฐจ: ์์คํ
๋ฅด๋ด์์ ๋ฐ๋์ผ๋ก ๋นํ.
15-18์ผ์ฐจ: 4์ผ๊ฐ ๋ฐ๋ ๋ฐฉ๋ฌธ.
|
17
|
์ ๋ฝ
| 3
|
์ง์ ์์ฑ
|
์ด 9์ผ ๋์ ์ ๋ฝ 3๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์ทจ๋ฆฌํ์์ 4์ผ์ ์ฌํํ๋ ค๊ณ ํฉ๋๋ค. 7์ผ๊ณผ 8์ผ ์ดํ ๋์ ์ทจ๋ฆฌํ์์ ์ด๋ฆฌ๋ ํ์ฌ์ ์ฐธ์ํด์ผ ํฉ๋๋ค. ๋ชจ๋์ฝ์์ 3์ผ ๋์ ๋จธ๋ฌด๋ฅผ ๊ฒ์
๋๋ค. ์ ๋
ธ๋ฐ์์ 4์ผ์ ๋ณด๋ด๋ ค๊ณ ํฉ๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ์ ๋
ธ๋ฐ์ ๋ชจ๋์ฝ, ์ทจ๋ฆฌํ์ ์ ๋
ธ๋ฐ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 9์ผ ๋์ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋ชจ๋์ฝ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋ชจ๋์ฝ์์ ์ ๋
ธ๋ฐ๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ์ ๋
ธ๋ฐ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์ ๋
ธ๋ฐ์์ ์ทจ๋ฆฌํ๋ก ๋นํ.
6-9์ผ์ฐจ: 4์ผ๊ฐ ์ทจ๋ฆฌํ ๋ฐฉ๋ฌธ.
|
You plan to visit 3 cities in Europe for a total of 9 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'll spend 4 days in Zurich, where you'll need to attend an event on the 7th and 8th. You will spend 3 days in Monaco. You want to spend 4 days in Genoa.
Here are the cities that have direct flights: Genoa and Monaco, Zurich and Genoa.
Plan a trip to visit the three cities in 9 days using direct flights.
|
Days 1-3: Visit Monaco for 3 days.
Day 3: Fly from Monaco to Genoa.
Days 3-6: Visit Genoa for 4 days.
Day 6: Fly from Genoa to Zurich.
Days 6-9: Visit Zurich for 4 days.
|
๋ณ์ ์ ์:
Z: ์ทจ๋ฆฌํ, M: ๋ชจ๋์ฝ, G: ์ ๋
ธ๋ฐ
a_Z: ์ทจ๋ฆฌํ ๋์ฐฉ์ผ, d_Z: ์ทจ๋ฆฌํ ์ถ๋ฐ์ผ
a_M: ๋ชจ๋์ฝ ๋์ฐฉ์ผ, d_M: ๋ชจ๋์ฝ ์ถ๋ฐ์ผ
a_G: ์ ๋
ธ๋ฐ ๋์ฐฉ์ผ, d_G: ์ ๋
ธ๋ฐ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_Z - a_Z + 1 = 4
d_M - a_M + 1 = 3
d_G - a_G + 1 = 4
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_Z, d_M, d_G) - min(a_Z, a_M, a_G) + 1 = 9
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
{7, 8} โ [a_Z, d_Z]
์งํญํธ์ด ์๋ ๋์:
(G โ M), (Z โ G)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋ชจ๋์ฝ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋ชจ๋์ฝ์์ ์ ๋
ธ๋ฐ๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ์ ๋
ธ๋ฐ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์ ๋
ธ๋ฐ์์ ์ทจ๋ฆฌํ๋ก ๋นํ.
6-9์ผ์ฐจ: 4์ผ๊ฐ ์ทจ๋ฆฌํ ๋ฐฉ๋ฌธ.
|
18
|
์ ๋ฝ
| 3
|
์ง์ ์์ฑ
|
์ด 7์ผ ๋์ ์ ๋ฝ 3๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ๋ฆฌ์ค๋ณธ์์ 2์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. 3์ผ ๋์ ํด๋ฅด์ฆ์ ๋จธ๋ฌด๋ฅผ ์์ ์
๋๋ค. ๋ง๋๋ฆฌ๋์์ 4์ผ๊ฐ ์ฌํ์ ์ฆ๊ธธ ๊ฒ์
๋๋ค. ์ฌํ 3-5์ผ์ฐจ์ ๋ง๋๋ฆฌ๋ ์๊ถ ํฌ์ด๋ฅผ ์์ฝํด๋์์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ง๋๋ฆฌ๋์ ๋ฆฌ์ค๋ณธ, ํด๋ฅด์ฆ์ ๋ง๋๋ฆฌ๋.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 7์ผ ๋์ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ๋ฆฌ์ค๋ณธ ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ๋ฆฌ์ค๋ณธ์์ ๋ง๋๋ฆฌ๋๋ก ๋นํ.
2-5์ผ์ฐจ: 4์ผ๊ฐ ๋ง๋๋ฆฌ๋ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋ง๋๋ฆฌ๋์์ ํด๋ฅด์ฆ๋ก ๋นํ.
5-7์ผ์ฐจ: 3์ผ๊ฐ ํด๋ฅด์ฆ ๋ฐฉ๋ฌธ.
|
You plan to visit 3 cities in Europe for a total of 7 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to spend 2 days in Lisbon. You'll be in Toulouse for 3 days. You'll spend 4 days in Madrid. You've booked a tour of the Royal Palace of Madrid for days 3-5 of your trip.
Here are the cities that have direct flights: Madrid and Lisbon, Toulouse and Madrid.
Plan your trip to visit three cities in seven days using direct flights.
|
Day 1-2: Visit Lisbon for 2 days.
Day 2: Fly from Lisbon to Madrid.
Days 2-5: Visit Madrid for 4 days.
Day 5: Fly from Madrid to Toulouse.
Days 5-7: Visit Toulouse for 3 days.
|
๋ณ์ ์ ์:
L: ๋ฆฌ์ค๋ณธ, T: ํด๋ฅด์ฆ, M: ๋ง๋๋ฆฌ๋
a_L: ๋ฆฌ์ค๋ณธ ๋์ฐฉ์ผ, d_L: ๋ฆฌ์ค๋ณธ ์ถ๋ฐ์ผ
a_T: ํด๋ฅด์ฆ ๋์ฐฉ์ผ, d_T: ํด๋ฅด์ฆ ์ถ๋ฐ์ผ
a_M: ๋ง๋๋ฆฌ๋ ๋์ฐฉ์ผ, d_M: ๋ง๋๋ฆฌ๋ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_L - a_L + 1 = 2
d_T - a_T + 1 = 3
d_M - a_M + 1 = 4
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_L, d_T, d_M) - min(a_L, a_T, a_M) + 1 = 7
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[3, 5] โฉ [a_M, d_M] โ โ
์งํญํธ์ด ์๋ ๋์:
(M โ L), (T โ M)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ๋ฆฌ์ค๋ณธ ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ๋ฆฌ์ค๋ณธ์์ ๋ง๋๋ฆฌ๋๋ก ๋นํ.
2-5์ผ์ฐจ: 4์ผ๊ฐ ๋ง๋๋ฆฌ๋ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋ง๋๋ฆฌ๋์์ ํด๋ฅด์ฆ๋ก ๋นํ.
5-7์ผ์ฐจ: 3์ผ๊ฐ ํด๋ฅด์ฆ ๋ฐฉ๋ฌธ.
|
19
|
์ ๋ฝ
| 3
|
์ง์ ์์ฑ
|
์ด 10์ผ ๋์ ์ ๋ฝ 3๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์ํ
๋ค์์ 5์ผ ๋์ ์ฌํ์ ์ฆ๊ธธ ๊ฒ์
๋๋ค. ์ฌํ 3-4์ผ์ฐจ์ ์ํ
๋ค์์ ์น๊ตฌ๋ฅผ ๋ง๋๊ธฐ๋ก ํ์ต๋๋ค. 3์ผ๊ฐ ์ด์คํ๋ถ์ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. ๋ถ๋ฅด๊ฐ์ค์์ 4์ผ ๋์ ๋จธ๋ฌด๋ฅผ ๊ฒ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ์ด์คํ๋ถ๊ณผ ์ํ
๋ค, ๋ถ๋ฅด๊ฐ์ค์ ์ด์คํ๋ถ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 10์ผ ๋์ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ์ํ
๋ค ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ์ํ
๋ค์์ ์ด์คํ๋ถ๋ก ๋นํ.
5-7์ผ์ฐจ: 3์ผ๊ฐ ์ด์คํ๋ถ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ์ด์คํ๋ถ์์ ๋ถ๋ฅด๊ฐ์ค๋ก ๋นํ.
7-10์ผ์ฐจ: 4์ผ๊ฐ ๋ถ๋ฅด๊ฐ์ค ๋ฐฉ๋ฌธ.
|
You plan to visit 3 cities in Europe for a total of 10 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You will spend five days in Athens. You will meet a friend in Athens on days 3-4 of your trip. You will visit Istanbul for three days. You will stay in Burgas for four days.
Here are the cities that have direct flights: Istanbul and Athens, Burgas and Istanbul.
Plan a trip to visit the three cities in 10 days using direct flights.
|
Days 1-5: Visit Athens for 5 days.
Day 5: Fly from Athens to Istanbul.
Days 5-7: Visit Istanbul for 3 days.
Day 7: Fly from Istanbul to Burgas.
Days 7-10: Visit Burgas for 4 days.
|
๋ณ์ ์ ์:
A: ์ํ
๋ค, I: ์ด์คํ๋ถ, B: ๋ถ๋ฅด๊ฐ์ค
a_A: ์ํ
๋ค ๋์ฐฉ์ผ, d_A: ์ํ
๋ค ์ถ๋ฐ์ผ
a_I: ์ด์คํ๋ถ ๋์ฐฉ์ผ, d_I: ์ด์คํ๋ถ ์ถ๋ฐ์ผ
a_B: ๋ถ๋ฅด๊ฐ์ค ๋์ฐฉ์ผ, d_B: ๋ถ๋ฅด๊ฐ์ค ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_A - a_A + 1 = 5
d_I - a_I + 1 = 3
d_B - a_B + 1 = 4
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_A, d_I, d_B) - min(a_A, a_I, a_B) + 1 = 10
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
{3, 4} โ [a_A, d_A]
์งํญํธ์ด ์๋ ๋์:
(I โ A), (B โ I)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ์ํ
๋ค ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ์ํ
๋ค์์ ์ด์คํ๋ถ๋ก ๋นํ.
5-7์ผ์ฐจ: 3์ผ๊ฐ ์ด์คํ๋ถ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ์ด์คํ๋ถ์์ ๋ถ๋ฅด๊ฐ์ค๋ก ๋นํ.
7-10์ผ์ฐจ: 4์ผ๊ฐ ๋ถ๋ฅด๊ฐ์ค ๋ฐฉ๋ฌธ.
|
20
|
์ ๋ฝ
| 3
|
์ง์ ์์ฑ
|
์ด 8์ผ ๋์ ์ ๋ฝ 3๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์์ด๋ผ์์ 4์ผ๊ฐ ๋จธ๋ฌด๋ฅผ ๊ฒ์
๋๋ค. 6-7์ผ ์ฌ์ด์ ์์ด๋ผ์์ ํํ ์ฐธ์์ด ์์ ๋์ด ์์ต๋๋ค. ํ๋ฆฐ์์ 3์ผ๊ฐ ๋จธ๋ฌด๋ฅผ ์์ ์
๋๋ค. 3์ผ ๋์ ํฌ์ฑํค์ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ํฌ์ฑํค์ ํ๋ฆฐ, ์์ด๋ผ์ ํฌ์ฑํค.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 8์ผ ๋์ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ํ๋ฆฐ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ํ๋ฆฐ์์ ํฌ์ฑํค๋ก ๋นํ.
3-5์ผ์ฐจ: 3์ผ๊ฐ ํฌ์ฑํค ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ํฌ์ฑํค์์ ์์ด๋ผ๋ก ๋นํ.
5-8์ผ์ฐจ: 4์ผ๊ฐ ์์ด๋ผ ๋ฐฉ๋ฌธ.
|
You plan to visit 3 cities in Europe for a total of 8 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You will be in Uppsala for 4 days. You will be attending a conference in Uppsala between days 6-7. You will be in Tallinn for 3 days. You will be in Helsinki for 3 days.
Here are the cities that have direct flights: Helsinki and Tallinn, Uppsala and Helsinki.
Plan your trip to visit the three cities in 8 days using direct flights.
|
Days 1-3: Visit Tallinn for 3 days.
Day 3: Fly from Tallinn to Helsinki.
Days 3-5: Visit Helsinki for 3 days.
Day 5: Fly from Helsinki to Uppsala.
Days 5-8: Visit Uppsala for 4 days.
|
์ํ์ ๊ตฌ์กฐํQ: ๋ณ์ ์ ์:
U: ์์ด๋ผ, T: ํ๋ฆฐ, H: ํฌ์ฑํค
a_U: ์์ด๋ผ ๋์ฐฉ์ผ, d_U: ์์ด๋ผ ์ถ๋ฐ์ผ
a_T: ํ๋ฆฐ ๋์ฐฉ์ผ, d_T: ํ๋ฆฐ ์ถ๋ฐ์ผ
a_H: ํฌ์ฑํค ๋์ฐฉ์ผ, d_H: ํฌ์ฑํค ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_U - a_U + 1 = 4
d_T - a_T + 1 = 3
d_H - a_H + 1 = 3
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_U, d_T, d_H) - min(a_U, a_T, a_H) + 1 = 8
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[6, 7] โฉ [a_U, d_U] โ โ
์งํญํธ์ด ์๋ ๋์:
(H โ T), (U โ H)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ํ๋ฆฐ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ํ๋ฆฐ์์ ํฌ์ฑํค๋ก ๋นํ.
3-5์ผ์ฐจ: 3์ผ๊ฐ ํฌ์ฑํค ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ํฌ์ฑํค์์ ์์ด๋ผ๋ก ๋นํ.
5-8์ผ์ฐจ: 4์ผ๊ฐ ์์ด๋ผ ๋ฐฉ๋ฌธ.
|
21
|
์ ๋ฝ
| 4
|
์ง์ ์์ฑ
|
์ด 11์ผ ๋์ ์ ๋ฝ 4๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์ํผ์, ์ผํ
ํธ๋ , ์ฝ์คํ์ฐจ๋ฅผ ๊ฐ๊ฐ 3์ผ ๋์ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. ์ผํ
ํธ๋ ๋ฅผ ๋์๋ค ์ค ๊ฐ์ฅ ๋ง์ง๋ง์ผ๋ก ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. 5์ผ ๋์ ์์นด๋ผ๋ฅผ ์ฌํํ ๊ฒ์
๋๋ค. ์ฌํ 3-4์ผ์ฐจ์ ์์นด๋ผ์์ ์ด๋ฆฌ๋ ์น๊ตฌ์ ๊ฒฐํผ์์ ์ฐธ์ํ ๊ฒ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ์ผํ
ํธ๋ ์ ์ํผ์, ์ผํ
ํธ๋ ์ ์ฝ์คํ์ฐจ, ์ํผ์์ ์์นด๋ผ, ์ํผ์์ ์ฝ์คํ์ฐจ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 11์ผ ๋์ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ์์นด๋ผ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ์์นด๋ผ์์ ์ํผ์๋ก ๋นํ.
5-7์ผ์ฐจ: 3์ผ๊ฐ ์ํผ์ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ์ํผ์์์ ์ฝ์คํ์ฐจ๋ก ๋นํ.
7-9์ผ์ฐจ: 3์ผ๊ฐ ์ฝ์คํ์ฐจ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ์ฝ์คํ์ฐจ์์ ์ผํ
ํธ๋ ๋ก ๋นํ.
9-11์ผ์ฐจ: 3์ผ๊ฐ ์ผํ
ํธ๋ ๋ฐฉ๋ฌธ.
|
You plan to visit 4 cities in Europe for a total of 11 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'll visit Sofia, Szentendre, and Constanta for 3 days each. You will visit Szentendre last among the cities. You will travel to Ankara for 5 days. On days 3-4 of your trip, you will attend a friend's wedding in Ankara.
Here are the cities that have direct flights: Szentendre and Sofia, Szentendre and Constanta, Sofia and Ankara, Sofia and Constanta.
Plan a trip to visit four cities in 11 days using direct flights.
|
Days 1-5: Visit Ankara for 5 days.
Day 5: Fly from Ankara to Sofia.
Days 5-7: Visit Sofia for 3 days.
Day 7: Fly from Sofia to Constanta.
Days 7-9: Visit Constanta for 3 days.
Day 9: Fly from Constanta to Szentendre.
Days 9-11: Visit Szentendre for 3 days.
|
๋ณ์ ์ ์:
S: ์ํผ์, Z: ์ผํ
ํธ๋ , C: ์ฝ์คํ์ฐจ, A: ์์นด๋ผ
a_S: ์ํผ์ ๋์ฐฉ์ผ, d_S: ์ํผ์ ์ถ๋ฐ์ผ
a_Z: ์ผํ
ํธ๋ ๋์ฐฉ์ผ, d_Z: ์ผํ
ํธ๋ ์ถ๋ฐ์ผ
a_C: ์ฝ์คํ์ฐจ ๋์ฐฉ์ผ, d_C: ์ฝ์คํ์ฐจ ์ถ๋ฐ์ผ
a_A: ์์นด๋ผ ๋์ฐฉ์ผ, d_A: ์์นด๋ผ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_S - a_S + 1 = 3
d_Z - a_Z + 1 = 3
d_C - a_C + 1 = 3
d_A - a_A + 1 = 5
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_S, d_Z, d_C, d_A) - min(a_S, a_Z, a_C, a_A) + 1 = 11
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
d_Z = 11
{3, 4} โ [a_A, d_A]
์งํญํธ์ด ์๋ ๋์:
(Z โ S), (Z โ C), (S โ A), (S โ C)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ์์นด๋ผ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ์์นด๋ผ์์ ์ํผ์๋ก ๋นํ.
5-7์ผ์ฐจ: 3์ผ๊ฐ ์ํผ์ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ์ํผ์์์ ์ฝ์คํ์ฐจ๋ก ๋นํ.
7-9์ผ์ฐจ: 3์ผ๊ฐ ์ฝ์คํ์ฐจ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ์ฝ์คํ์ฐจ์์ ์ผํ
ํธ๋ ๋ก ๋นํ.
9-11์ผ์ฐจ: 3์ผ๊ฐ ์ผํ
ํธ๋ ๋ฐฉ๋ฌธ.
|
22
|
์ ๋ฝ
| 4
|
์ง์ ์์ฑ
|
์ด 11์ผ ๋์ ์ ๋ฝ 4๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ๋ํด๋ฆฌ์์ 6์ผ์ ์ฌํํ๋ ค๊ณ ํฉ๋๋ค. ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ์์ 2์ผ ๋์ ๋จธ๋ฌด๋ฅด๋ ค๊ณ ํฉ๋๋ค. 3์ผ ๋์์ ์ธ์ค๋ธ๋ฃจํฌ์ ๋จธ๋ฌด๋ฅผ ๊ฒ์
๋๋ค. ํ์ ์์ 3์ผ์ ์ฌํํ ๊ฒ์
๋๋ค. 2์ผ๊ณผ 4์ผ ์ฌ์ด์ ํ์ ์์ ๋จธ๋ฌด๋ฅผ ์์๋ฅผ ๋ฏธ๋ฆฌ ์์ฝํด๋์์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ์ธ์ค๋ธ๋ฃจํฌ์ ํ์ , ์ธ์ค๋ธ๋ฃจํฌ์ ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ, ์ธ์ค๋ธ๋ฃจํฌ์ ๋ํด๋ฆฌ, ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ์ ํ์ .
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 11์ผ ๋์ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ์์ ํ์ ์ผ๋ก ๋นํ.
2-4์ผ์ฐจ: 3์ผ๊ฐ ํ์ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ํ์ ์์ ์ธ์ค๋ธ๋ฃจํฌ๋ก ๋นํ.
4-6์ผ์ฐจ: 3์ผ๊ฐ ์ธ์ค๋ธ๋ฃจํฌ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์ธ์ค๋ธ๋ฃจํฌ์์ ๋ํด๋ฆฌ๋ก ๋นํ.
6-11์ผ์ฐจ: 6์ผ๊ฐ ๋ํด๋ฆฌ ๋ฐฉ๋ฌธ.
|
You plan to visit 4 cities in Europe for a total of 11 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to spend 6 days in Naples. You'll spend 2 days in Bratislava. You'll stay in Innsbruck for 3 days. You'll spend 3 days traveling in Plzen. You have pre-booked a place to stay in Plzen between days 2 and 4.
Here are the cities that have direct flights: Innsbruck and Plzen, Innsbruck and Bratislava, Innsbruck and Naples, Bratislava and Plzen.
Plan a trip to visit four cities in 11 days using direct flights.
|
Day 1-2: Visit Bratislava for 2 days.
Day 2: Fly from Bratislava to Plzen.
Days 2-4: Visit Plzen for 3 days.
Day 4: Fly from Plzen to Innsbruck.
Days 4-6: Visit Innsbruck for 3 days.
Day 6: Fly from Innsbruck to Naples.
Days 6-11: Visit Naples for 6 days.
|
๋ณ์ ์ ์:
N: ๋ํด๋ฆฌ, B: ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ, I: ์ธ์ค๋ธ๋ฃจํฌ, P: ํ์
a_N: ๋ํด๋ฆฌ ๋์ฐฉ์ผ, d_N: ๋ํด๋ฆฌ ์ถ๋ฐ์ผ
a_B: ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ ๋์ฐฉ์ผ, d_B: ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ ์ถ๋ฐ์ผ
a_I: ์ธ์ค๋ธ๋ฃจํฌ ๋์ฐฉ์ผ, d_I: ์ธ์ค๋ธ๋ฃจํฌ ์ถ๋ฐ์ผ
a_P: ํ์ ๋์ฐฉ์ผ, d_P: ํ์ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_N - a_N + 1 = 6
d_B - a_B + 1 = 2
d_I - a_I + 1 = 3
d_P - a_P + 1 = 3
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_N, d_B, d_I, d_P) - min(a_N, a_B, a_I, a_P) + 1 = 11
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[2, 4] โฉ [a_P, d_P] โ โ
์งํญํธ์ด ์๋ ๋์:
(I โ P), (I โ B), (I โ N), (B โ P)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ์์ ํ์ ์ผ๋ก ๋นํ.
2-4์ผ์ฐจ: 3์ผ๊ฐ ํ์ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ํ์ ์์ ์ธ์ค๋ธ๋ฃจํฌ๋ก ๋นํ.
4-6์ผ์ฐจ: 3์ผ๊ฐ ์ธ์ค๋ธ๋ฃจํฌ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์ธ์ค๋ธ๋ฃจํฌ์์ ๋ํด๋ฆฌ๋ก ๋นํ.
6-11์ผ์ฐจ: 6์ผ๊ฐ ๋ํด๋ฆฌ ๋ฐฉ๋ฌธ.
|
23
|
์ ๋ฝ
| 4
|
์ง์ ์์ฑ
|
์ด 13์ผ ๋์ ์ ๋ฝ 4๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. 5์ผ๊ฐ ๋น๋ฐ์ค์์ ์ฌํ์ ํ ๊ฒ์
๋๋ค. ์ ํธ๋ผ์์๋ 5์ผ ๋์ ๋จธ๋ฌด๋ฅผ ๊ฒ์
๋๋ค. 10์ผ๊ณผ 12์ผ ์ฌ์ด ์ ํธ๋ผ์ ์๋ ์น๊ตฌ ์ง์ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. 2์ผ ๋์์ ๋ผ๋ก์
์์ ๋จธ๋ฌผ๊ณ ์ถ์ต๋๋ค. ์นด๋ํ์์ 4์ผ์ ์ฌํํ ์์ ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ผ๋ก์
๊ณผ ์นด๋ํ, ๋น๋ฐ์ค์ ๋ผ๋ก์
, ์ ํธ๋ผ์ ๋น๋ฐ์ค.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 13์ผ ๋์ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ์นด๋ํ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ์นด๋ํ์์ ๋ผ๋ก์
๋ก ๋นํ.
4-5์ผ์ฐจ: 2์ผ๊ฐ ๋ผ๋ก์
๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋ผ๋ก์
์์ ๋น๋ฐ์ค๋ก ๋นํ.
5-9์ผ์ฐจ: 5์ผ๊ฐ ๋น๋ฐ์ค ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ๋น๋ฐ์ค์์ ์ ํธ๋ผ๋ก ๋นํ.
9-13์ผ์ฐจ: 5์ผ๊ฐ ์ ํธ๋ผ ๋ฐฉ๋ฌธ.
|
You plan to visit 4 cities in Europe for a total of 13 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'll spend five days in Bilbao. You'll spend 5 days in Sintra. Between the 10th and 12th, you'll visit a friend in Sintra. You want to stay in La Rochelle for 2 days. You will be traveling from Cardiff for 4 days.
Here are the cities that have direct flights: La Rochelle and Cardiff, Bilbao and La Rochelle, Sintra and Bilbao.
Plan your trip to visit four cities in 13 days using direct flights.
|
Days 1-4: Visit Cardiff for 4 days.
Day 4: Fly from Cardiff to La Rochelle.
Days 4-5: Visit La Rochelle for 2 days.
Day 5: Fly from La Rochelle to Bilbao.
Days 5-9: Visit Bilbao for 5 days.
Day 9: Fly from Bilbao to Sintra.
Days 9-13: Visit Sintra for 5 days.
|
๋ณ์ ์ ์:
B: ๋น๋ฐ์ค, S: ์ ํธ๋ผ, L: ๋ผ๋ก์
, C: ์นด๋ํ
a_B: ๋น๋ฐ์ค ๋์ฐฉ์ผ, d_B: ๋น๋ฐ์ค ์ถ๋ฐ์ผ
a_S: ์ ํธ๋ผ ๋์ฐฉ์ผ, d_S: ์ ํธ๋ผ ์ถ๋ฐ์ผ
a_L: ๋ผ๋ก์
๋์ฐฉ์ผ, d_L: ๋ผ๋ก์
์ถ๋ฐ์ผ
a_C: ์นด๋ํ ๋์ฐฉ์ผ, d_C: ์นด๋ํ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_B - a_B + 1 = 5
d_S - a_S + 1 = 5
d_L - a_L + 1 = 2
d_C - a_C + 1 = 4
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_B, d_S, d_L, d_C) - min(a_B, a_S, a_L, a_C) + 1 = 13
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[10, 12] โฉ [a_S, d_S] โ โ
์งํญํธ์ด ์๋ ๋์:
(L โ C), (B โ L), (S โ B)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ์นด๋ํ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ์นด๋ํ์์ ๋ผ๋ก์
๋ก ๋นํ.
4-5์ผ์ฐจ: 2์ผ๊ฐ ๋ผ๋ก์
๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋ผ๋ก์
์์ ๋น๋ฐ์ค๋ก ๋นํ.
5-9์ผ์ฐจ: 5์ผ๊ฐ ๋น๋ฐ์ค ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ๋น๋ฐ์ค์์ ์ ํธ๋ผ๋ก ๋นํ.
9-13์ผ์ฐจ: 5์ผ๊ฐ ์ ํธ๋ผ ๋ฐฉ๋ฌธ.
|
24
|
์ ๋ฝ
| 4
|
์ง์ ์์ฑ
|
์ด 12์ผ ๋์ ์ ๋ฝ 4๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ํด๋ฃจ์ง๋ํฌ์นด์์ 3์ผ๊ฐ ๋จธ๋ฌผ ๊ฒ์
๋๋ค. ์ํผ์์์ 4์ผ ๊ฐ ๋จธ๋ฌผ ์์ ์
๋๋ค. 5์ผ์ ์ํผ์์ ์๋ ๋ ์คํ ๋์ ์์ฝํด๋์์ต๋๋ค. 5์ผ ๋์ ๋ฏธ์์ฝ์ธ ์์ ์ฌํ์ ํ ๊ฒ์
๋๋ค. 9-11์ผ ์ฌ์ด์ ์น๊ตฌ์ ๋ฏธ์์ฝ์ธ ์์ ๊ฐ์ด ์ฌํํ๊ธฐ๋ก ํ์ต๋๋ค. ์ด์คํ๋ถ์์ 3์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ฏธ์์ฝ์ธ ์ ํด๋ฃจ์ง๋ํฌ์นด, ์ํผ์์ ํด๋ฃจ์ง๋ํฌ์นด, ์ํผ์์ ๋ฏธ์์ฝ์ธ , ์ด์คํ๋ถ๊ณผ ์ํผ์.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 12์ผ ๋์ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ์ด์คํ๋ถ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ์ด์คํ๋ถ์์ ์ํผ์๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ์ํผ์ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์ํผ์์์ ํด๋ฃจ์ง๋ํฌ์นด๋ก ๋นํ.
6-8์ผ์ฐจ: 3์ผ๊ฐ ํด๋ฃจ์ง๋ํฌ์นด ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ํด๋ฃจ์ง๋ํฌ์นด์์ ๋ฏธ์์ฝ์ธ ๋ก ๋นํ.
8-12์ผ์ฐจ: 5์ผ๊ฐ ๋ฏธ์์ฝ์ธ ๋ฐฉ๋ฌธ.
|
You plan to visit 4 cities in Europe for a total of 12 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You will be staying in Cluj-Napoca for 3 days. You will be staying in Sofia for 4 days. You have reservations at a restaurant in Sofia on the 5th. You will be traveling from Miskolc for 5 days. You will be traveling with a friend in Miskolc between 9-11. You want to spend 3 days in Istanbul.
Here are the cities that have direct flights: Miskolc and Cluj-Napoca, Sofia and Cluj-Napoca, Sofia and Miskolc, Istanbul and Sofia.
Plan a trip to visit four cities in 12 days using direct flights.
|
Days 1-3: Visit Istanbul for 3 days.
Day 3: Fly from Istanbul to Sofia.
Days 3-6: Visit Sofia for 4 days.
Day 6: Fly from Sofia to Cluj-Napoca.
Days 6-8: Visit Cluj-Napoca for 3 days.
Day 8: Fly from Cluj-Napoca to Miskolc.
Days 8-12: Visit Miskolc for 5 days.
|
๋ณ์ ์ ์:
C: ํด๋ฃจ์ง๋ํฌ์นด, S: ์ํผ์, M: ๋ฏธ์์ฝ์ธ , I: ์ด์คํ๋ถ
a_C: ํด๋ฃจ์ง๋ํฌ์นด ๋์ฐฉ์ผ, d_C: ํด๋ฃจ์ง๋ํฌ์นด ์ถ๋ฐ์ผ
a_S: ์ํผ์ ๋์ฐฉ์ผ, d_S: ์ํผ์ ์ถ๋ฐ์ผ
a_M: ๋ฏธ์์ฝ์ธ ๋์ฐฉ์ผ, d_M: ๋ฏธ์์ฝ์ธ ์ถ๋ฐ์ผ
a_I: ์ด์คํ๋ถ ๋์ฐฉ์ผ, d_I: ์ด์คํ๋ถ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_C - a_C + 1 = 3
d_S - a_S + 1 = 4
d_M - a_M + 1 = 5
d_I - a_I + 1 = 3
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_C, d_S, d_M, d_I) - min(a_C, a_S, a_M, a_I) + 1 = 12
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
5 โ [a_S, d_S]
[9, 11] โฉ [a_M, d_M] โ โ
์งํญํธ์ด ์๋ ๋์:
(M โ C), (S โ C), (S โ M), (I โ S)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ์ด์คํ๋ถ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ์ด์คํ๋ถ์์ ์ํผ์๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ์ํผ์ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์ํผ์์์ ํด๋ฃจ์ง๋ํฌ์นด๋ก ๋นํ.
6-8์ผ์ฐจ: 3์ผ๊ฐ ํด๋ฃจ์ง๋ํฌ์นด ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ํด๋ฃจ์ง๋ํฌ์นด์์ ๋ฏธ์์ฝ์ธ ๋ก ๋นํ.
8-12์ผ์ฐจ: 5์ผ๊ฐ ๋ฏธ์์ฝ์ธ ๋ฐฉ๋ฌธ.
|
25
|
์ ๋ฝ
| 5
|
์ง์ ์์ฑ
|
์ด 16์ผ ๋์ ์ ๋ฝ 5๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ํ๋ฆฐ๊ณผ ๋ฏผ์คํฌ๋ฅผ ๊ฐ๊ฐ 3์ผ๊ฐ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. 14-16์ผ ์ฌ์ด์ ๋ฏผ์คํฌ์์ ๋ถ๋ชจ๋์ ๋ง๋๊ธฐ๋ก ํ์ต๋๋ค. ๋น๋ด์ค์ ๋ฆฌ๊ฐ์์ ๊ฐ๊ฐ 5์ผ์ ๋จธ๋ฌด๋ฅผ ์์ ์
๋๋ค. 6-10์ผ์ฐจ์ ๋ฆฌ๊ฐ์์ ๋จธ๋ฌด๋ฅผ ์์๋ฅผ ์์ฝํด๋์์ต๋๋ค. ์ค์ธ๋ฃจ๋ฅผ 4์ผ ๋์ ์ฌํํ๋ ค๊ณ ํฉ๋๋ค. ์ฌํ 3์ผ์ฐจ์ ์ค์ธ๋ฃจ ์ค์ฌ์ ์๋ ์๋น์ ์์ฝํด๋์์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ํ๋ฆฐ๊ณผ ์ค์ธ๋ฃจ, ๋ฆฌ๊ฐ์ ๋น๋ด์ค, ๋ฆฌ๊ฐ์ ํ๋ฆฐ, ๋ฆฌ๊ฐ์ ๋ฏผ์คํฌ, ๋น๋ด์ค์ ๋ฏผ์คํฌ, ๋น๋ด์ค์ ํ๋ฆฐ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 16์ผ ๋์ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ์ค์ธ๋ฃจ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ์ค์ธ๋ฃจ์์ ํ๋ฆฐ์ผ๋ก ๋นํ.
4-6์ผ์ฐจ: 3์ผ๊ฐ ํ๋ฆฐ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ํ๋ฆฐ์์ ๋ฆฌ๊ฐ๋ก ๋นํ.
6-10์ผ์ฐจ: 5์ผ๊ฐ ๋ฆฌ๊ฐ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ๋ฆฌ๊ฐ์์ ๋น๋ด์ค๋ก ๋นํ.
10-14์ผ์ฐจ: 5์ผ๊ฐ ๋น๋ด์ค ๋ฐฉ๋ฌธ.
14์ผ์ฐจ: ๋น๋ด์ค์์ ๋ฏผ์คํฌ๋ก ๋นํ.
14-16์ผ์ฐจ: 3์ผ๊ฐ ๋ฏผ์คํฌ ๋ฐฉ๋ฌธ.
|
You plan to visit 5 cities in Europe for a total of 16 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You will visit Tallinn and Minsk for 3 days each. Between days 14-16, you will meet your parents in Minsk. You'll spend 5 days each in Vilnius and Riga. You've booked a place to stay in Riga for days 6-10. You want to travel to Oulu for 4 days. You've booked a restaurant in the center of Oulu for day 3 of your trip.
Here are the cities that have direct flights: Tallinn and Oulu, Riga and Vilnius, Riga and Tallinn, Riga and Minsk, Vilnius and Minsk, Vilnius and Tallinn.
Plan a trip to visit five cities in 16 days with direct flights.
|
Days 1-4: Visit Oulu for 4 days.
Day 4: Fly from Oulu to Tallinn.
Days 4-6: Visit Tallinn for 3 days.
Day 6: Fly from Tallinn to Riga.
Days 6-10: Visit Riga for 5 days.
Day 10: Fly from Riga to Vilnius.
Days 10-14: Visit Vilnius for 5 days.
Day 14: Fly from Vilnius to Minsk.
Days 14-16: Visit Minsk for 3 days.
|
๋ณ์ ์ ์:
T: ํ๋ฆฐ, M: ๋ฏผ์คํฌ, V: ๋น๋ด์ค, R: ๋ฆฌ๊ฐ, O: ์ค์ธ๋ฃจ
a_T: ํ๋ฆฐ ๋์ฐฉ์ผ, d_T: ํ๋ฆฐ ์ถ๋ฐ์ผ
a_M: ๋ฏผ์คํฌ ๋์ฐฉ์ผ, d_M: ๋ฏผ์คํฌ ์ถ๋ฐ์ผ
a_V: ๋น๋ด์ค ๋์ฐฉ์ผ, d_V: ๋น๋ด์ค ์ถ๋ฐ์ผ
a_R: ๋ฆฌ๊ฐ ๋์ฐฉ์ผ, d_R: ๋ฆฌ๊ฐ ์ถ๋ฐ์ผ
a_O: ์ค์ธ๋ฃจ ๋์ฐฉ์ผ, d_O: ์ค์ธ๋ฃจ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_T - a_T + 1 = 3
d_M - a_M + 1 = 3
d_V - a_V + 1 = 5
d_R - a_R + 1 = 5
d_O - a_O + 1 = 4
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_T, d_M, d_V, d_R, d_O) - min(a_T, a_M, a_V, a_R, a_O) + 1 = 16
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[14, 16] โฉ [a_M, d_M] โ โ
[6, 10] โ [a_R, d_R]
a_O โค 3 โค d_O
์งํญํธ์ด ์๋ ๋์:
(T โ O), (R โ V), (R โ T), (R โ M), (V โ M), (V โ T)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ์ค์ธ๋ฃจ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ์ค์ธ๋ฃจ์์ ํ๋ฆฐ์ผ๋ก ๋นํ.
4-6์ผ์ฐจ: 3์ผ๊ฐ ํ๋ฆฐ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ํ๋ฆฐ์์ ๋ฆฌ๊ฐ๋ก ๋นํ.
6-10์ผ์ฐจ: 5์ผ๊ฐ ๋ฆฌ๊ฐ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ๋ฆฌ๊ฐ์์ ๋น๋ด์ค๋ก ๋นํ.
10-14์ผ์ฐจ: 5์ผ๊ฐ ๋น๋ด์ค ๋ฐฉ๋ฌธ.
14์ผ์ฐจ: ๋น๋ด์ค์์ ๋ฏผ์คํฌ๋ก ๋นํ.
14-16์ผ์ฐจ: 3์ผ๊ฐ ๋ฏผ์คํฌ ๋ฐฉ๋ฌธ.
|
26
|
์ ๋ฝ
| 5
|
์ง์ ์์ฑ
|
์ด 13์ผ ๋์ ์ ๋ฝ 5๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ๊ณจ์จ์ด์์ 2์ผ๊ฐ ๋จธ๋ฌด๋ฅผ ์์ ์
๋๋ค. ์ฌ๋ฌ ๋์ ์ค ๊ณจ์จ์ด๋ฅผ ์ฒ์์ผ๋ก ๋ฐฉ๋ฌธํ๋ ค๊ณ ํฉ๋๋ค. 4์ผ ๋์ ๋ฃฉ์
๋ถ๋ฅดํฌ๋ฅผ ์ฌํํ ๊ฒ์
๋๋ค. ์๋ ๋ฒ๋ฌ์์ 6์ผ์ ๋ณด๋ผ ๊ฒ์
๋๋ค. ๋ง๊ทธ๋ฐ๋ถ๋ฅดํฌ๋ฅผ 3์ผ ๋์ ๋ฐฉ๋ฌธํ ์์ ์
๋๋ค. 2์ผ์ ํจํธ์์ ๋ณด๋ผ ๊ฒ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ์๋ ๋ฒ๋ฌ์ ๊ณจ์จ์ด, ํจํธ์ ์๋ ๋ฒ๋ฌ, ๋ฃฉ์
๋ถ๋ฅดํฌ์ ํจํธ, ๋ง๊ทธ๋ฐ๋ถ๋ฅดํฌ์ ๋ฃฉ์
๋ถ๋ฅดํฌ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 13์ผ ๋์ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ๊ณจ์จ์ด ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ๊ณจ์จ์ด์์ ์๋ ๋ฒ๋ฌ๋ก ๋นํ.
2-7์ผ์ฐจ: 6์ผ๊ฐ ์๋ ๋ฒ๋ฌ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ์๋ ๋ฒ๋ฌ์์ ํจํธ๋ก ๋นํ.
7-8์ผ์ฐจ: 2์ผ๊ฐ ํจํธ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ํจํธ์์ ๋ฃฉ์
๋ถ๋ฅดํฌ๋ก ๋นํ.
8-11์ผ์ฐจ: 4์ผ๊ฐ ๋ฃฉ์
๋ถ๋ฅดํฌ ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ๋ฃฉ์
๋ถ๋ฅดํฌ์์ ๋ง๊ทธ๋ฐ๋ถ๋ฅดํฌ๋ก ๋นํ.
11-13์ผ์ฐจ: 3์ผ๊ฐ ๋ง๊ทธ๋ฐ๋ถ๋ฅดํฌ ๋ฐฉ๋ฌธ.
|
You plan to visit 5 cities in Europe for a total of 13 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'll spend 2 days in Galway. You're visiting Galway for the first time among several cities. You'll be traveling to Luxembourg for 4 days. You will spend 6 days in Edinburgh. You will be traveling to Magdeburg for 3 days. You will spend 2 days in Ghent.
Here are the cities that have direct flights: Edinburgh and Galway, Ghent and Edinburgh, Luxembourg and Ghent, Magdeburg and Luxembourg.
Plan a trip to visit five cities in 13 days with direct flights.
|
Days 1-2: Visit Galway for 2 days.
Day 2: Fly from Galway to Edinburgh.
Days 2-7: Visit Edinburgh for 6 days.
Day 7: Fly from Edinburgh to Ghent.
Days 7-8: Visit Ghent for 2 days.
Day 8: Fly from Ghent to Luxembourg.
Days 8-11: Visit Luxembourg for 4 days.
Day 11: Fly from Luxembourg to Magdeburg.
Days 11-13: Visit Magdeburg for 3 days.
|
๋ณ์ ์ ์:
G: ๊ณจ์จ์ด, L: ๋ฃฉ์
๋ถ๋ฅดํฌ, E: ์๋ ๋ฒ๋ฌ, M: ๋ง๊ทธ๋ฐ๋ถ๋ฅดํฌ, H: ํจํธ
a_G: ๊ณจ์จ์ด ๋์ฐฉ์ผ, d_G: ๊ณจ์จ์ด ์ถ๋ฐ์ผ
a_L: ๋ฃฉ์
๋ถ๋ฅดํฌ ๋์ฐฉ์ผ, d_L: ๋ฃฉ์
๋ถ๋ฅดํฌ ์ถ๋ฐ์ผ
a_E: ์๋ ๋ฒ๋ฌ ๋์ฐฉ์ผ, d_E: ์๋ ๋ฒ๋ฌ ์ถ๋ฐ์ผ
a_M: ๋ง๊ทธ๋ฐ๋ถ๋ฅดํฌ ๋์ฐฉ์ผ, d_M: ๋ง๊ทธ๋ฐ๋ถ๋ฅดํฌ ์ถ๋ฐ์ผ
a_H: ํจํธ ๋์ฐฉ์ผ, d_H: ํจํธ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_G - a_G + 1 = 2
d_L - a_L + 1 = 4
d_E - a_E + 1 = 6
d_M - a_M + 1 = 3
d_H - a_H + 1 = 2
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_G, d_L, d_E, d_M, d_H) - min(a_G, a_L, a_E, a_M, a_H) + 1 = 13
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
a_G = min(a_G, a_L, a_E, a_M, a_H)
์งํญํธ์ด ์๋ ๋์:
(E โ G), (H โ E), (L โ H), (M โ L)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ๊ณจ์จ์ด ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ๊ณจ์จ์ด์์ ์๋ ๋ฒ๋ฌ๋ก ๋นํ.
2-7์ผ์ฐจ: 6์ผ๊ฐ ์๋ ๋ฒ๋ฌ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ์๋ ๋ฒ๋ฌ์์ ํจํธ๋ก ๋นํ.
7-8์ผ์ฐจ: 2์ผ๊ฐ ํจํธ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ํจํธ์์ ๋ฃฉ์
๋ถ๋ฅดํฌ๋ก ๋นํ.
8-11์ผ์ฐจ: 4์ผ๊ฐ ๋ฃฉ์
๋ถ๋ฅดํฌ ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ๋ฃฉ์
๋ถ๋ฅดํฌ์์ ๋ง๊ทธ๋ฐ๋ถ๋ฅดํฌ๋ก ๋นํ.
11-13์ผ์ฐจ: 3์ผ๊ฐ ๋ง๊ทธ๋ฐ๋ถ๋ฅดํฌ ๋ฐฉ๋ฌธ.
|
27
|
์ ๋ฝ
| 5
|
์ง์ ์์ฑ
|
์ด 14์ผ ๋์ ์ ๋ฝ 5๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ํค์๋์ฐ์ 2์ผ ๋์ ๋จธ๋ฌด๋ฅด๊ณ ์ ํฉ๋๋ค. ๋ก๋ฒ ์น์์ 4์ผ์ ๋ณด๋ผ ์์ ์
๋๋ค. 9-12์ผ ์ฌ์ด์๋ ๋ก๋ฒ ์น์ ์์ ๊ฒ์
๋๋ค. ์ฝ์คํ์ฐจ์์ 4์ผ์ ์ฌํํ ๊ฒ์
๋๋ค. ์ด์ฆ๋ฏธ๋ฅด์์ 3์ผ๊ฐ ๋จธ๋ฌด๋ฅผ ์์ ์
๋๋ค. 12์ผ๊ณผ 13์ผ ์ฌ์ด์ ์ด์ฆ๋ฏธ๋ฅด์์ ์ถ์ ๋ฅผ ์ฆ๊ธธ ๊ฒ์
๋๋ค. 5์ผ ๋์ ํค์ด์ฐ์ ๋จธ๋ฌด๋ฅผ ๊ฒ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ํค์๋์ฐ์ ํค์ด์ฐ, ๋ก๋ฒ ์น์ ์ด์ฆ๋ฏธ๋ฅด, ๋ก๋ฒ ์น์ ํค์๋์ฐ, ์ฝ์คํ์ฐจ์ ๋ก๋ฒ ์น, ํค์๋์ฐ์ ์ฝ์คํ์ฐจ, ํค์๋์ฐ์ ์ด์ฆ๋ฏธ๋ฅด.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 14์ผ ๋์ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ํค์ด์ฐ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ํค์ด์ฐ์์ ํค์๋์ฐ๋ก ๋นํ.
5-6์ผ์ฐจ: 2์ผ๊ฐ ํค์๋์ฐ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ํค์๋์ฐ์์ ์ฝ์คํ์ฐจ๋ก ๋นํ.
6-9์ผ์ฐจ: 4์ผ๊ฐ ์ฝ์คํ์ฐจ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ์ฝ์คํ์ฐจ์์ ๋ก๋ฒ ์น๋ก ๋นํ.
9-12์ผ์ฐจ: 4์ผ๊ฐ ๋ก๋ฒ ์น ๋ฐฉ๋ฌธ.
12์ผ์ฐจ: ๋ก๋ฒ ์น์์ ์ด์ฆ๋ฏธ๋ฅด๋ก ๋นํ.
12-14์ผ์ฐจ: 3์ผ๊ฐ ์ด์ฆ๋ฏธ๋ฅด ๋ฐฉ๋ฌธ.
|
You plan to visit 5 cities in Europe for a total of 14 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You plan to stay in Kishinev for 2 days. You'll spend 4 days in Roveci. You will be in Roveci between days 9-12. You'll spend 4 days in Constanta. You'll spend 3 days in Izmir. Between the 12th and 13th, you'll enjoy a festival in Izmir. You'll be in Kyiv for 5 days.
Here are the cities that have direct flights: Kishinev and Kyiv, Roveci and Izmir, Roveci and Kishinev, Constanta and Roveci, Kishinev and Constanta, Kishinev and Izmir.
Plan a trip to visit five cities in 14 days with direct flights.
|
Days 1-5: Visit Kyiv for 5 days.
Day 5: Fly from Kyiv to Kishinev.
Days 5-6: Visit Kishinev for 2 days.
Day 6: Fly from Kishinev to Constanta.
Days 6-9: Visit Constanta for 4 days.
Day 9: Fly from Constanta to Roveci.
Days 9-12: Visit Roveci for 4 days.
Day 12: Fly from Roveci to Izmir.
Days 12-14: Visit Izmir for 3 days.
|
๋ณ์ ์ ์:
K: ํค์๋์ฐ, L: ๋ก๋ฒ ์น, C: ์ฝ์คํ์ฐจ, I: ์ด์ฆ๋ฏธ๋ฅด, Y: ํค์ด์ฐ
a_K: ํค์๋์ฐ ๋์ฐฉ์ผ, d_K: ํค์๋์ฐ ์ถ๋ฐ์ผ
a_L: ๋ก๋ฒ ์น ๋์ฐฉ์ผ, d_L: ๋ก๋ฒ ์น ์ถ๋ฐ์ผ
a_C: ์ฝ์คํ์ฐจ ๋์ฐฉ์ผ, d_C: ์ฝ์คํ์ฐจ ์ถ๋ฐ์ผ
a_I: ์ด์ฆ๋ฏธ๋ฅด ๋์ฐฉ์ผ, d_I: ์ด์ฆ๋ฏธ๋ฅด ์ถ๋ฐ์ผ
a_Y: ํค์ด์ฐ ๋์ฐฉ์ผ, d_Y: ํค์ด์ฐ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_K - a_K + 1 = 2
d_L - a_L + 1 = 4
d_C - a_C + 1 = 4
d_I - a_I + 1 = 3
d_Y - a_Y + 1 = 5
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_K, d_L, d_C, d_I, d_Y) - min(a_K, a_L, a_C, a_I, a_Y) + 1 = 14
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[9, 12] โฉ [a_L, d_L] โ โ
{12, 13} โฉ [a_I, d_I] โ โ
์งํญํธ์ด ์๋ ๋์:
(K โ Y), (L โ I), (L โ K), (C โ L), (K โ C), (K โ I)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ํค์ด์ฐ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ํค์ด์ฐ์์ ํค์๋์ฐ๋ก ๋นํ.
5-6์ผ์ฐจ: 2์ผ๊ฐ ํค์๋์ฐ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ํค์๋์ฐ์์ ์ฝ์คํ์ฐจ๋ก ๋นํ.
6-9์ผ์ฐจ: 4์ผ๊ฐ ์ฝ์คํ์ฐจ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ์ฝ์คํ์ฐจ์์ ๋ก๋ฒ ์น๋ก ๋นํ.
9-12์ผ์ฐจ: 4์ผ๊ฐ ๋ก๋ฒ ์น ๋ฐฉ๋ฌธ.
12์ผ์ฐจ: ๋ก๋ฒ ์น์์ ์ด์ฆ๋ฏธ๋ฅด๋ก ๋นํ.
12-14์ผ์ฐจ: 3์ผ๊ฐ ์ด์ฆ๋ฏธ๋ฅด ๋ฐฉ๋ฌธ.
|
28
|
์ ๋ฝ
| 5
|
์ง์ ์์ฑ
|
์ด 15์ผ ๋์ ์ ๋ฝ 5๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ๋ก๋ฒ ์น์์ 5์ผ์ ๋ณด๋ผ ๊ฒ์
๋๋ค. 3์ผ๊ฐ์ ์ํ๋ฆฌ์๋ฅผ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. ์ํ๋ฆฌ์๊ฐ ์ฒซ๋ฒ์งธ ์ฌ์ ์ง์์ผ๋ฉด ์ข๊ฒ ์ต๋๋ค. ํฌ๋๊ณ ๋ฆฌ์ฐจ์์ 3์ผ์ ๋จธ๋ฌด๋ฅผ ๊ฒ์
๋๋ค. ํฌ๋๊ณ ๋ฆฌ์ฐจ๊ฐ ์ฌํ์ ๋ง์ง๋ง ๋์๊ฐ ๋์์ผ๋ฉด ์ข๊ฒ ์ต๋๋ค. 5์ผ ๋์ ํํธ๋ผ์ค์ ๋จธ๋ฌผ ์์ ์
๋๋ค. ํํธ๋ผ์ค์์ 4-6์ผ ์ฌ์ด์ ํํฐ๋ฅผ ์ฐธ์ํ ์์ ์
๋๋ค. ํฐ๋ผ๋์์ 3์ผ์ ๋ณด๋ด๊ณ ์ ํฉ๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ํฌ๋๊ณ ๋ฆฌ์ฐจ์ ๋ก๋ฒ ์น, ํฌ๋๊ณ ๋ฆฌ์ฐจ์ ํํธ๋ผ์ค, ํฐ๋ผ๋์ ๋ก๋ฒ ์น, ํฐ๋ผ๋์ ํํธ๋ผ์ค, ์ํ๋ฆฌ์์ ๋ก๋ฒ ์น, ์ํ๋ฆฌ์์ ํํธ๋ผ์ค.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 15์ผ ๋์ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ์ํ๋ฆฌ์ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ์ํ๋ฆฌ์์์ ํํธ๋ผ์ค๋ก ๋นํ.
3-7์ผ์ฐจ: 5์ผ๊ฐ ํํธ๋ผ์ค ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ํํธ๋ผ์ค์์ ํฐ๋ผ๋๋ก ๋นํ.
7-9์ผ์ฐจ: 3์ผ๊ฐ ํฐ๋ผ๋ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ํฐ๋ผ๋์์ ๋ก๋ฒ ์น๋ก ๋นํ.
9-13์ผ์ฐจ: 5์ผ๊ฐ ๋ก๋ฒ ์น ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ๋ก๋ฒ ์น์์ ํฌ๋๊ณ ๋ฆฌ์ฐจ๋ก ๋นํ.
13-15์ผ์ฐจ: 3์ผ๊ฐ ํฌ๋๊ณ ๋ฆฌ์ฐจ ๋ฐฉ๋ฌธ.
|
You plan to visit 5 cities in Europe for a total of 15 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'll spend 5 days in Roveci. You'll spend 3 days in Antalya. You want Antalya to be the first stop on your itinerary. You will spend 3 days in Podgorica. You want Podgorica to be the last city on your trip. You will stay in Patras for 5 days. You will be attending a party between days 4-6 in Patras. You want to spend 3 days in Tirana.
Here are the cities that have direct flights: Podgorica and Roveci, Podgorica and Patras, Tirana and Roveci, Tirana and Patras, Antalya and Roveci, Antalya and Patras.
Plan a trip to visit five cities in 15 days with direct flights.
|
Days 1-3: Visit Antalya for 3 days.
Day 3: Fly from Antalya to Patras.
Days 3-7: Visit Patras for 5 days.
Day 7: Fly from Patras to Tirana.
Days 7-9: Visit Tirana for 3 days.
Day 9: Fly from Tirana to Roveci.
Days 9-13: Visit Roveci for 5 days.
Day 13: Fly from Roveci to Podgorica.
Days 13-15: Visit Podgorica for 3 days.
|
๋ณ์ ์ ์:
L: ๋ก๋ฒ ์น, A: ์ํ๋ฆฌ์, P: ํฌ๋๊ณ ๋ฆฌ์ฐจ, Pa: ํํธ๋ผ์ค, T: ํฐ๋ผ๋
a_L: ๋ก๋ฒ ์น ๋์ฐฉ์ผ, d_L: ๋ก๋ฒ ์น ์ถ๋ฐ์ผ
a_A: ์ํ๋ฆฌ์ ๋์ฐฉ์ผ, d_A: ์ํ๋ฆฌ์ ์ถ๋ฐ์ผ
a_P: ํฌ๋๊ณ ๋ฆฌ์ฐจ ๋์ฐฉ์ผ, d_P: ํฌ๋๊ณ ๋ฆฌ์ฐจ ์ถ๋ฐ์ผ
a_Pa: ํํธ๋ผ์ค ๋์ฐฉ์ผ, d_Pa: ํํธ๋ผ์ค ์ถ๋ฐ์ผ
a_T: ํฐ๋ผ๋ ๋์ฐฉ์ผ, d_T: ํฐ๋ผ๋ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_L - a_L + 1 = 5
d_A - a_A + 1 = 3
d_P - a_P + 1 = 3
d_Pa - a_Pa + 1 = 5
d_T - a_T + 1 = 3
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_L, d_A, d_P, d_Pa, d_T) - min(a_L, a_A, a_P, a_Pa, a_T) + 1 = 15
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
a_A = 1
d_P = 15
[4, 6] โฉ [a_Pa, d_Pa] โ โ
์งํญํธ์ด ์๋ ๋์:
(P โ L), (P โ Pa), (T โ L), (T โ Pa), (A โ L), (A โ Pa)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ์ํ๋ฆฌ์ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ์ํ๋ฆฌ์์์ ํํธ๋ผ์ค๋ก ๋นํ.
3-7์ผ์ฐจ: 5์ผ๊ฐ ํํธ๋ผ์ค ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ํํธ๋ผ์ค์์ ํฐ๋ผ๋๋ก ๋นํ.
7-9์ผ์ฐจ: 3์ผ๊ฐ ํฐ๋ผ๋ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ํฐ๋ผ๋์์ ๋ก๋ฒ ์น๋ก ๋นํ.
9-13์ผ์ฐจ: 5์ผ๊ฐ ๋ก๋ฒ ์น ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ๋ก๋ฒ ์น์์ ํฌ๋๊ณ ๋ฆฌ์ฐจ๋ก ๋นํ.
13-15์ผ์ฐจ: 3์ผ๊ฐ ํฌ๋๊ณ ๋ฆฌ์ฐจ ๋ฐฉ๋ฌธ.
|
29
|
์ ๋ฝ
| 6
|
์ง์ ์์ฑ
|
์ด 20์ผ ๋์ ์ ๋ฝ 6๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์นด์ฐ๋์ค์์ 5์ผ ๋์ ๋จธ๋ฌด๋ฅด๋ ค๊ณ ํฉ๋๋ค. 11์ผ๊ณผ 15์ผ ์ฌ์ด์ ์นด์ฐ๋์ค์์ ๊ฐ์กฑ ๋ชจ์์ด ์์ต๋๋ค. ํ
ํ๋ ๋ฅผ 6์ผ๊ฐ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. 2-4์ผ ์ฌ์ด์ ํ
ํ๋ ์์ ํํ์ ์ฐธ์ํด์ผ ํฉ๋๋ค. 3์ผ ๋์ ์ฒด์์ค์ ๋จธ๋ฌด๋ฅผ ๊ฒ์
๋๋ค. ํ๋ก๋๋์์ 4์ผ ๋์ ์ฌํ์ ์ฆ๊ธฐ๋ ค ํฉ๋๋ค. 3์ผ ๋์์ ํ๋ฅดํค์ฐ์ ์์ ๊ฒ์
๋๋ค. ๋ฐ๊ฐ์์ 4์ผ์ ๋จธ๋ฌด๋ฅผ ์์ ์
๋๋ค. 6์ผ๊ณผ 9์ผ ์ฌ์ด์ ๋จธ๋ฌด๋ฅผ ํธํ
์ ๋ฐ๊ฐ์ ์์ฝํด๋์์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ฐ๊ฐ์ ์ฒด์์ค, ๋ฐ๊ฐ์ ํ๋ฅดํค์ฐ, ํ๋ฅดํค์ฐ์ ํ๋ก๋๋, ํ๋ก๋๋์ ํ
ํ๋ , ํ
ํ๋ ์ ๋ฐ๊ฐ, ํ
ํ๋ ์ ์นด์ฐ๋์ค, ์ฒด์์ค์ ์นด์ฐ๋์ค, ์ฒด์์ค์ ํ๋ฅดํค์ฐ, ํ๋ก๋๋์ ์นด์ฐ๋์ค, ํ๋ก๋๋์ ๋ฐ๊ฐ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 20์ผ ๋์ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-6์ผ์ฐจ: 6์ผ๊ฐ ํ
ํ๋ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ํ
ํ๋ ์์ ๋ฐ๊ฐ๋ก ๋นํ.
6-9์ผ์ฐจ: 4์ผ๊ฐ ๋ฐ๊ฐ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ๋ฐ๊ฐ์์ ์ฒด์์ค๋ก ๋นํ.
9-11์ผ์ฐจ: 3์ผ๊ฐ ์ฒด์์ค ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ์ฒด์์ค์์ ์นด์ฐ๋์ค๋ก ๋นํ.
11-15์ผ์ฐจ: 5์ผ๊ฐ ์นด์ฐ๋์ค ๋ฐฉ๋ฌธ.
15์ผ์ฐจ: ์นด์ฐ๋์ค์์ ํ๋ก๋๋๋ก ๋นํ.
15-18์ผ์ฐจ: 4์ผ๊ฐ ํ๋ก๋๋ ๋ฐฉ๋ฌธ.
18์ผ์ฐจ: ํ๋ก๋๋์์ ํ๋ฅดํค์ฐ๋ก ๋นํ.
18-20์ผ์ฐจ: 3์ผ๊ฐ ํ๋ฅดํค์ฐ ๋ฐฉ๋ฌธ.
|
You plan to visit 6 cities in Europe for a total of 20 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You plan to stay in Kaunas for 5 days. There is a family gathering in Kaunas between the 11th and the 15th. You will be visiting Tampere for 6 days. You need to attend a conference in Tampere between the 2nd and 4th. You'll be in Cesis for 3 days. You'll be in Hrodna for 4 days. You'll be in Kharkiv for 3 days. You'll be in Balga for 4 days. You've booked a hotel in Balga where you'll stay between the 6th and 9th.
Here are the cities that have direct flights: Balga and Cesis, Balga and Kharkiv, Kharkiv and Hrodna, Hrodna and Tampere, Tampere and Balga, Tampere and Kaunas, Cesis and Kaunas, Cesis and Kharkiv, Hrodna and Kaunas, Hrodna and Balga.
Plan a trip to visit six cities in 20 days with direct flights.
|
Days 1-6: Visit Tampere for 6 days.
Day 6: Fly from Tampere to Balga.
Days 6-9: Visit Balga for 4 days.
Day 9: Fly from Balga to Cesis.
Days 9-11: Visit Cesis for 3 days.
Day 11: Fly from Cesis to Kaunas.
Days 11-15: Visit Kaunas for 5 days.
Day 15: Fly from Kaunas to Hrodna.
Days 15-18: Visit Hrodna for 4 days.
Day 18: Fly from Hrodna to Kharkiv.
Days 18-20: Visit Kharkiv for 3 days.
|
๋ณ์ ์ ์:
K: ์นด์ฐ๋์ค, T: ํ
ํ๋ , C: ์ฒด์์ค, H: ํ๋ก๋๋, Kh: ํ๋ฅดํค์ฐ, V: ๋ฐ๊ฐ
a_K: ์นด์ฐ๋์ค ๋์ฐฉ์ผ, d_K: ์นด์ฐ๋์ค ์ถ๋ฐ์ผ
a_T: ํ
ํ๋ ๋์ฐฉ์ผ, d_T: ํ
ํ๋ ์ถ๋ฐ์ผ
a_C: ์ฒด์์ค ๋์ฐฉ์ผ, d_C: ์ฒด์์ค ์ถ๋ฐ์ผ
a_H: ํ๋ก๋๋ ๋์ฐฉ์ผ, d_H: ํ๋ก๋๋ ์ถ๋ฐ์ผ
a_Kh: ํ๋ฅดํค์ฐ ๋์ฐฉ์ผ, d_Kh: ํ๋ฅดํค์ฐ ์ถ๋ฐ์ผ
a_V: ๋ฐ๊ฐ ๋์ฐฉ์ผ, d_V: ๋ฐ๊ฐ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_K - a_K + 1 = 5
d_T - a_T + 1 = 6
d_C - a_C + 1 = 3
d_H - a_H + 1 = 4
d_Kh - a_Kh + 1 = 3
d_V - a_V + 1 = 4
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_K, d_T, d_C, d_H, d_Kh, d_V) - min(a_K, a_T, a_C, a_H, a_Kh, a_V) + 1 = 20
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[11, 15] โฉ [a_K, d_K] โ โ
[2, 4] โฉ [a_T, d_T] โ โ
[6, 9] โฉ [a_V, d_V] โ โ
์งํญํธ์ด ์๋ ๋์:
(V โ C), (V โ Kh), (Kh โ H), (H โ T), (T โ V), (T โ K), (C โ K), (C โ Kh), (H โ K), (H โ V)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-6์ผ์ฐจ: 6์ผ๊ฐ ํ
ํ๋ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ํ
ํ๋ ์์ ๋ฐ๊ฐ๋ก ๋นํ.
6-9์ผ์ฐจ: 4์ผ๊ฐ ๋ฐ๊ฐ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ๋ฐ๊ฐ์์ ์ฒด์์ค๋ก ๋นํ.
9-11์ผ์ฐจ: 3์ผ๊ฐ ์ฒด์์ค ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ์ฒด์์ค์์ ์นด์ฐ๋์ค๋ก ๋นํ.
11-15์ผ์ฐจ: 5์ผ๊ฐ ์นด์ฐ๋์ค ๋ฐฉ๋ฌธ.
15์ผ์ฐจ: ์นด์ฐ๋์ค์์ ํ๋ก๋๋๋ก ๋นํ.
15-18์ผ์ฐจ: 4์ผ๊ฐ ํ๋ก๋๋ ๋ฐฉ๋ฌธ.
18์ผ์ฐจ: ํ๋ก๋๋์์ ํ๋ฅดํค์ฐ๋ก ๋นํ.
18-20์ผ์ฐจ: 3์ผ๊ฐ ํ๋ฅดํค์ฐ ๋ฐฉ๋ฌธ.
|
30
|
์ ๋ฝ
| 6
|
์ง์ ์์ฑ
|
์ด 21์ผ ๋์ ์ ๋ฝ 6๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์์นด๋ผ์์ 4์ผ๊ฐ ๋จธ๋ฌผ ๊ฒ์
๋๋ค. 6์ผ๊ฐ ์คํ๋ฆฌ๋๋ฅผ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. 5์ผ ๋์ ๋ผ๋ฆฌ์ฌ์์ ๋จธ๋ฌผ ๊ฒ์
๋๋ค. ๋ฒ ์ค๊ทธ๋ผ๋๋ฅผ 5์ผ ๋์ ์ฌํํ ์์ ์
๋๋ค. 18-20์ผ ์ฌ์ด์๋ ๋ฌด์กฐ๊ฑด ๋ฒ ์ค๊ทธ๋ผ๋์ ์์ด์ผ ํฉ๋๋ค. 3์ผ๊ฐ ํฐ๋ผ๋๋ฅผ ์ฌํํ๋ ค๊ณ ํฉ๋๋ค. ๋ชฌํ๋์์ 3์ผ๊ฐ ์์ ๊ฒ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ผ๋ฆฌ์ฌ์ ์์นด๋ผ, ํฐ๋ผ๋์ ๋ผ๋ฆฌ์ฌ, ๋ชฌํ๋์ ๋ฒ ์ค๊ทธ๋ผ๋, ์คํ๋ฆฌ๋์ ๋ชฌํ๋, ํฐ๋ผ๋์ ์คํ๋ฆฌ๋.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 21์ผ ๋์ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ์์นด๋ผ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ์์นด๋ผ์์ ๋ผ๋ฆฌ์ฌ๋ก ๋นํ.
4-8์ผ์ฐจ: 5์ผ๊ฐ ๋ผ๋ฆฌ์ฌ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ๋ผ๋ฆฌ์ฌ์์ ํฐ๋ผ๋๋ก ๋นํ.
8-10์ผ์ฐจ: 3์ผ๊ฐ ํฐ๋ผ๋ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ํฐ๋ผ๋์์ ์คํ๋ฆฌ๋๋ก ๋นํ.
10-15์ผ์ฐจ: 6์ผ๊ฐ ์คํ๋ฆฌ๋ ๋ฐฉ๋ฌธ.
15์ผ์ฐจ: ์คํ๋ฆฌ๋์์ ๋ชฌํ๋๋ก ๋นํ.
15-17์ผ์ฐจ: 3์ผ๊ฐ ๋ชฌํ๋ ๋ฐฉ๋ฌธ.
17์ผ์ฐจ: ๋ชฌํ๋์์ ๋ฒ ์ค๊ทธ๋ผ๋๋ก ๋นํ.
17-21์ผ์ฐจ: 5์ผ๊ฐ ๋ฒ ์ค๊ทธ๋ผ๋ ๋ฐฉ๋ฌธ.
|
You plan to visit 6 cities in Europe for a total of 21 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'll be in Ankara for 4 days. You'll visit Ohrid for 6 days. You'll stay in Larissa for 5 days. You'll travel to Belgrade for 5 days. You must be in Belgrade between days 18-20. You will be traveling to Tirana for 3 days. You will be in Montana for 3 days.
Here are the cities that have direct flights: Larissa and Ankara, Tirana and Larissa, Montana and Belgrade, Ohrid and Montana, Tirana and Ohrid.
Plan a trip to visit six cities in 21 days with direct flights.
|
Days 1-4: Visit Ankara for 4 days.
Day 4: Fly from Ankara to Larissa.
Days 4-8: Visit Larissa for 5 days.
Day 8: Fly from Larissa to Tirana.
Days 8-10: Visit Tirana for 3 days.
Day 10: Fly from Tirana to Ohrid.
Days 10-15: Visit Ohrid for 6 days.
Day 15: Fly from Ohrid to Montana.
Days 15-17: Visit Montana for 3 days.
Day 17: Fly from Montana to Belgrade.
Days 17-21: Visit Belgrade for 5 days.
|
๋ณ์ ์ ์:
A: ์์นด๋ผ, O: ์คํ๋ฆฌ๋, L: ๋ผ๋ฆฌ์ฌ, B: ๋ฒ ์ค๊ทธ๋ผ๋, T: ํฐ๋ผ๋, M: ๋ชฌํ๋
a_A: ์์นด๋ผ ๋์ฐฉ์ผ, d_A: ์์นด๋ผ ์ถ๋ฐ์ผ
a_O: ์คํ๋ฆฌ๋ ๋์ฐฉ์ผ, d_O: ์คํ๋ฆฌ๋ ์ถ๋ฐ์ผ
a_L: ๋ผ๋ฆฌ์ฌ ๋์ฐฉ์ผ, d_L: ๋ผ๋ฆฌ์ฌ ์ถ๋ฐ์ผ
a_B: ๋ฒ ์ค๊ทธ๋ผ๋ ๋์ฐฉ์ผ, d_B: ๋ฒ ์ค๊ทธ๋ผ๋ ์ถ๋ฐ์ผ
a_T: ํฐ๋ผ๋ ๋์ฐฉ์ผ, d_T: ํฐ๋ผ๋ ์ถ๋ฐ์ผ
a_M: ๋ชฌํ๋ ๋์ฐฉ์ผ, d_M: ๋ชฌํ๋ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_A - a_A + 1 = 4
d_O - a_O + 1 = 6
d_L - a_L + 1 = 5
d_B - a_B + 1 = 5
d_T - a_T + 1 = 3
d_M - a_M + 1 = 3
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_A, d_O, d_L, d_B, d_T, d_M) - min(a_A, a_O, a_L, a_B, a_T, a_M) + 1 = 21
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[18, 20] โ [a_B, d_B]
์งํญํธ์ด ์๋ ๋์:
(L โ A), (T โ L), (M โ B), (O โ M), (T โ O)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ์์นด๋ผ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ์์นด๋ผ์์ ๋ผ๋ฆฌ์ฌ๋ก ๋นํ.
4-8์ผ์ฐจ: 5์ผ๊ฐ ๋ผ๋ฆฌ์ฌ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ๋ผ๋ฆฌ์ฌ์์ ํฐ๋ผ๋๋ก ๋นํ.
8-10์ผ์ฐจ: 3์ผ๊ฐ ํฐ๋ผ๋ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ํฐ๋ผ๋์์ ์คํ๋ฆฌ๋๋ก ๋นํ.
10-15์ผ์ฐจ: 6์ผ๊ฐ ์คํ๋ฆฌ๋ ๋ฐฉ๋ฌธ.
15์ผ์ฐจ: ์คํ๋ฆฌ๋์์ ๋ชฌํ๋๋ก ๋นํ.
15-17์ผ์ฐจ: 3์ผ๊ฐ ๋ชฌํ๋ ๋ฐฉ๋ฌธ.
17์ผ์ฐจ: ๋ชฌํ๋์์ ๋ฒ ์ค๊ทธ๋ผ๋๋ก ๋นํ.
17-21์ผ์ฐจ: 5์ผ๊ฐ ๋ฒ ์ค๊ทธ๋ผ๋ ๋ฐฉ๋ฌธ.
|
31
|
์ ๋ฝ
| 6
|
์ง์ ์์ฑ
|
์ด 17์ผ ๋์ ์ ๋ฝ 6๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ๋ดํ๊ทธ์์ 3์ผ์ ๋จธ๋ฌผ๊ณ ์ ํฉ๋๋ค. ๋ดํ๊ทธ์ ๋์ฐฉํ๋ 14์ผ ์น๊ตฌ๊ฐ ๊ณตํญ์ผ๋ก ํฝ์
์ ์จ๋ค๊ณ ํฉ๋๋ค. ๊ทธ๋ผ๋๋ค๋ฅผ 5์ผ ๋์ ์ฌํํ ๊ฒ์
๋๋ค. ๋์ค์ 4์ผ ๋์ ์์ ์์ ์
๋๋ค. 10์ผ๋ถํฐ 12์ผ ์ฌ์ด์ ๋์ค์์ ์ด๋ฆฌ๋ ํจ์
์ผ๋ฅผ ๋ณด๋ฌ๊ฐ ์์ ์
๋๋ค. 5์ผ๊ฐ ๋ฆฌ์ค๋ณธ์ ์์ ์์ ์
๋๋ค. 2-4์ผ ์ฌ์ด์ ๋ฆฌ์ค๋ณธ์ ์๋ ์น์ฒ์ง์ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. ๋ฃจ๋ฒค์์๋ 3์ผ์ ๋ณด๋ด๋ ค๊ณ ํฉ๋๋ค. ๋๋ฅธ๋ฒ ๋ฅดํฌ์์๋ 2์ผ์ ๋ณด๋ผ ๊ฒ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋์ค์ ๊ทธ๋ผ๋๋ค, ๋์ค์ ๋ฆฌ์ค๋ณธ, ๋๋ฅธ๋ฒ ๋ฅดํฌ์ ๋ดํ๊ทธ, ๋๋ฅธ๋ฒ ๋ฅดํฌ์ ๊ทธ๋ผ๋๋ค, ๋ฃจ๋ฒค๊ณผ ๋ฆฌ์ค๋ณธ, ๋ฃจ๋ฒค๊ณผ ๋ดํ๊ทธ, ๋ฃจ๋ฒค๊ณผ ๋์ค, ๋ฆฌ์ค๋ณธ๊ณผ ๋ดํ๊ทธ, ๋ฆฌ์ค๋ณธ๊ณผ ๊ทธ๋ผ๋๋ค.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 17์ผ ๋์ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ๋ฆฌ์ค๋ณธ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋ฆฌ์ค๋ณธ์์ ๊ทธ๋ผ๋๋ค๋ก ๋นํ.
5-9์ผ์ฐจ: 5์ผ๊ฐ ๊ทธ๋ผ๋๋ค ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ๊ทธ๋ผ๋๋ค์์ ๋์ค๋ก ๋นํ.
9-12์ผ์ฐจ: 4์ผ๊ฐ ๋์ค ๋ฐฉ๋ฌธ.
12์ผ์ฐจ: ๋์ค์์ ๋ฃจ๋ฒค์ผ๋ก ๋นํ.
12-14์ผ์ฐจ: 3์ผ๊ฐ ๋ฃจ๋ฒค ๋ฐฉ๋ฌธ.
14์ผ์ฐจ: ๋ฃจ๋ฒค์์ ๋ดํ๊ทธ๋ก ๋นํ.
14-16์ผ์ฐจ: 3์ผ๊ฐ ๋ดํ๊ทธ ๋ฐฉ๋ฌธ.
16์ผ์ฐจ: ๋ดํ๊ทธ์์ ๋๋ฅธ๋ฒ ๋ฅดํฌ๋ก ๋นํ.
16-17์ผ์ฐจ: 2์ผ๊ฐ ๋๋ฅธ๋ฒ ๋ฅดํฌ ๋ฐฉ๋ฌธ.
|
You plan to visit 6 cities in Europe for a total of 17 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You plan to spend 3 days in The Hague. A friend is picking you up at the airport on the 14th when you arrive in The Hague. You will be traveling to Granada for 5 days. You will be in Nice for 4 days. You are going to a fashion show in Nice between the 10th and 12th. You will be in Lisbon for five days. Between days 2 and 4, you will visit a relative in Lisbon. You're going to spend 3 days in Leuven. You will spend 2 days in Nuremberg.
Here are the cities that have direct flights: Nice and Granada, Nice and Lisbon, Nuremberg and The Hague, Nuremberg and Granada, Leuven and Lisbon, Leuven and The Hague, Leuven and Nice, Lisbon and The Hague, Lisbon and Granada.
Plan a trip to visit six cities in 17 days with direct flights.
|
Days 1-5: Visit Lisbon for 5 days.
Day 5: Fly from Lisbon to Granada.
Days 5-9: Visit Granada for 5 days.
Day 9: Fly from Granada to Nice.
Days 9-12: Visit Nice for 4 days.
Day 12: Fly from Nice to Leuven.
Days 12-14: Visit Leuven for 3 days.
Day 14: Fly from Leuven to The Hague.
Days 14-16: Visit The Hague for 3 days.
Day 16: Fly from The Hague to Nuremberg.
Days 16-17: Visit Nuremberg for 2 days.
|
๋ณ์ ์ ์:
D: ๋ดํ๊ทธ, G: ๊ทธ๋ผ๋๋ค, N: ๋์ค, L: ๋ฆฌ์ค๋ณธ, R: ๋ฃจ๋ฒค, Nu: ๋๋ฅธ๋ฒ ๋ฅดํฌ
a_D: ๋ดํ๊ทธ ๋์ฐฉ์ผ, d_D: ๋ดํ๊ทธ ์ถ๋ฐ์ผ
a_G: ๊ทธ๋ผ๋๋ค ๋์ฐฉ์ผ, d_G: ๊ทธ๋ผ๋๋ค ์ถ๋ฐ์ผ
a_N: ๋์ค ๋์ฐฉ์ผ, d_N: ๋์ค ์ถ๋ฐ์ผ
a_L: ๋ฆฌ์ค๋ณธ ๋์ฐฉ์ผ, d_L: ๋ฆฌ์ค๋ณธ ์ถ๋ฐ์ผ
a_R: ๋ฃจ๋ฒค ๋์ฐฉ์ผ, d_R: ๋ฃจ๋ฒค ์ถ๋ฐ์ผ
a_Nu: ๋๋ฅธ๋ฒ ๋ฅดํฌ ๋์ฐฉ์ผ, d_Nu: ๋๋ฅธ๋ฒ ๋ฅดํฌ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_D - a_D + 1 = 3
d_G - a_G + 1 = 5
d_N - a_N + 1 = 4
d_L - a_L + 1 = 5
d_R - a_R + 1 = 3
d_Nu - a_Nu + 1 = 2
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_D, d_G, d_N, d_L, d_R, d_Nu) - min(a_D, a_G, a_N, a_L, a_R, a_Nu) + 1 = 17
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
a_D = 14
[10, 12] โฉ [a_N, d_N] โ โ
[2, 4] โฉ [a_L, d_L] โ โ
์งํญํธ์ด ์๋ ๋์:
(N โ G), (N โ L), (Nu โ D), (Nu โ G), (R โ L), (R โ D), (R โ N), (L โ D), (L โ G)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ๋ฆฌ์ค๋ณธ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋ฆฌ์ค๋ณธ์์ ๊ทธ๋ผ๋๋ค๋ก ๋นํ.
5-9์ผ์ฐจ: 5์ผ๊ฐ ๊ทธ๋ผ๋๋ค ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ๊ทธ๋ผ๋๋ค์์ ๋์ค๋ก ๋นํ.
9-12์ผ์ฐจ: 4์ผ๊ฐ ๋์ค ๋ฐฉ๋ฌธ.
12์ผ์ฐจ: ๋์ค์์ ๋ฃจ๋ฒค์ผ๋ก ๋นํ.
12-14์ผ์ฐจ: 3์ผ๊ฐ ๋ฃจ๋ฒค ๋ฐฉ๋ฌธ.
14์ผ์ฐจ: ๋ฃจ๋ฒค์์ ๋ดํ๊ทธ๋ก ๋นํ.
14-16์ผ์ฐจ: 3์ผ๊ฐ ๋ดํ๊ทธ ๋ฐฉ๋ฌธ.
16์ผ์ฐจ: ๋ดํ๊ทธ์์ ๋๋ฅธ๋ฒ ๋ฅดํฌ๋ก ๋นํ.
16-17์ผ์ฐจ: 2์ผ๊ฐ ๋๋ฅธ๋ฒ ๋ฅดํฌ ๋ฐฉ๋ฌธ.
|
32
|
์ ๋ฝ
| 6
|
์ง์ ์์ฑ
|
์ด 18์ผ ๋์ ์ ๋ฝ 6๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. 6์ผ๊ฐ ํ ์ํํธ์์ ์ฌํ์ ํ๊ณ ์ ํฉ๋๋ค. 6-11์ผ ์ฌ์ด ํ ์ํํธ์์ ๋ถ๋ชจ๋์ ๋ง๋๊ธฐ๋ก ํ์ต๋๋ค. ๋ฅ๋ธ๋ด๋์์ 3์ผ์ ๋จธ๋ฌด๋ฅผ ๊ฒ์
๋๋ค. ํ์น๋ฅผ 3์ผ๊ฐ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. ๋ณผ๋ก๋๋ฅผ 4์ผ ๋์ ์ฌํํ๋ ค๊ณ ํฉ๋๋ค. ๋ณผ๋ก๋์์ ์ ๋ช
ํ ์๋น์ ์ฌํ 5์ผ์ฐจ์ ์์ฝํด๋์์ต๋๋ค. 4์ผ ๋์ ๋๋ธ๋ก๋ธ๋ํฌ์ ๋จธ๋ฌด๋ฅด๋ ค๊ณ ํฉ๋๋ค. 13-15์ผ ์ฌ์ด์ ๋๋ธ๋ก๋ธ๋ํฌ์์ ์น๊ตฌ๋ฅผ ๋ง๋ ๊ฒ์
๋๋ค. 3์ผ๊ฐ ๋ฃจ์ฒด๋ฅธ์์ ์์ ์์ ์
๋๋ค. ์ฌํ 2-3์ผ์ฐจ์๋ ์น๊ตฌ์ ๋ฃจ์ฒด๋ฅธ์์ ๋ํ์ ํ ๊ฒ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋๋ธ๋ก๋ธ๋ํฌ์ ๋ฅ๋ธ๋ด๋, ๋ฃจ์ฒด๋ฅธ๊ณผ ๋๋ธ๋ก๋ธ๋ํฌ, ๋ฃจ์ฒด๋ฅธ๊ณผ ๋ณผ๋ก๋, ๋ฃจ์ฒด๋ฅธ๊ณผ ๋ฅ๋ธ๋ด๋, ํ ์ํํธ์ ๋ฅ๋ธ๋ด๋, ํ ์ํํธ์ ๋ณผ๋ก๋, ํ์น์ ๋ณผ๋ก๋, ํ์น์ ๋๋ธ๋ก๋ํฌ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 18์ผ ๋์ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋ฃจ์ฒด๋ฅธ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋ฃจ์ฒด๋ฅธ์์ ๋ณผ๋ก๋๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ๋ณผ๋ก๋ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋ณผ๋ก๋์์ ํ ์ํํธ๋ก ๋นํ.
6-11์ผ์ฐจ: 6์ผ๊ฐ ํ ์ํํธ ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ํ ์ํํธ์์ ๋ฅ๋ธ๋ด๋์ผ๋ก ๋นํ.
11-13์ผ์ฐจ: 3์ผ๊ฐ ๋ฅ๋ธ๋ด๋ ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ๋ฅ๋ธ๋ด๋์์ ๋๋ธ๋ก๋ธ๋ํฌ๋ก ๋นํ.
13-16์ผ์ฐจ: 4์ผ๊ฐ ๋๋ธ๋ก๋ธ๋ํฌ ๋ฐฉ๋ฌธ.
16์ผ์ฐจ: ๋๋ธ๋ก๋ธ๋ํฌ์์ ํ์น๋ก ๋นํ.
16-18์ผ์ฐจ: 3์ผ๊ฐ ํ์น ๋ฐฉ๋ฌธ.
|
You plan to visit 6 cities in Europe for a total of 18 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You're planning to spend 6 days in Hallstatt. You'll meet your parents between day 6 and 11 in Hallstatt. You will spend 3 days in Ljubljana. You're traveling to Pecs for 3 days. You want to travel to Bologna for 4 days. You have a reservation at a famous restaurant in Bologna for day 5 of your trip. You plan to stay in Dubrovnik for 4 days. You will be meeting a friend in Dubrovnik between days 13-15. You will be in Lucerne for 3 days. On days 2-3 of your trip, you will join your friend in Lucerne.
Here are the cities that have direct flights: Dubrovnik and Ljubljana, Lucerne and Dubrovnik, Lucerne and Bologna, Lucerne and Ljubljana, Hallstatt and Ljubljana, Hallstatt and Bologna, Pecs and Bologna, Pecs and Dubrovnik.
Plan your trip to visit six cities in 18 days with direct flights.
|
Days 1-3: Visit Lucerne for 3 days.
Day 3: Fly from Lucerne to Bologna.
Days 3-6: Visit Bologna for 4 days.
Day 6: Fly from Bologna to Hallstatt.
Days 6-11: Visit Hallstatt for 6 days.
Day 11: Fly from Hallstatt to Ljubljana.
Days 11-13: Visit Ljubljana for 3 days.
Day 13: Fly from Ljubljana to Dubrovnik.
Days 13-16: Visit Dubrovnik for 4 days.
Day 16: Fly from Dubrovnik to Pecs.
Days 16-18: Visit Pecs for 3 days.
|
๋ณ์ ์ ์:
H: ํ ์ํํธ, L: ๋ฅ๋ธ๋ด๋, P: ํ์น, B: ๋ณผ๋ก๋, D: ๋๋ธ๋ก๋ธ๋ํฌ, Lu: ๋ฃจ์ฒด๋ฅธ
a_H: ํ ์ํํธ ๋์ฐฉ์ผ, d_H: ํ ์ํํธ ์ถ๋ฐ์ผ
a_L: ๋ฅ๋ธ๋ด๋ ๋์ฐฉ์ผ, d_L: ๋ฅ๋ธ๋ด๋ ์ถ๋ฐ์ผ
a_P: ํ์น ๋์ฐฉ์ผ, d_P: ํ์น ์ถ๋ฐ์ผ
a_B: ๋ณผ๋ก๋ ๋์ฐฉ์ผ, d_B: ๋ณผ๋ก๋ ์ถ๋ฐ์ผ
a_D: ๋๋ธ๋ก๋ธ๋ํฌ ๋์ฐฉ์ผ, d_D: ๋๋ธ๋ก๋ธ๋ํฌ ์ถ๋ฐ์ผ
a_Lu: ๋ฃจ์ฒด๋ฅธ ๋์ฐฉ์ผ, d_Lu: ๋ฃจ์ฒด๋ฅธ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_H - a_H + 1 = 6
d_L - a_L + 1 = 3
d_P - a_P + 1 = 3
d_B - a_B + 1 = 4
d_D - a_D + 1 = 4
d_Lu - a_Lu + 1 = 3
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_H, d_L, d_P, d_B, d_D, d_Lu) - min(a_H, a_L, a_P, a_B, a_D, a_Lu) + 1 = 18
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[6, 11] โฉ [a_H, d_H] โ โ
a_B โค 5 โค d_B
[13, 15] โฉ [a_D, d_D] โ โ
{2, 3} โ [a_Lu, d_Lu]
์งํญํธ์ด ์๋ ๋์:
(D โ L), (Lu โ D), (Lu โ B), (Lu โ L), (H โ L), (H โ B), (P โ B), (P โ D)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋ฃจ์ฒด๋ฅธ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋ฃจ์ฒด๋ฅธ์์ ๋ณผ๋ก๋๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ๋ณผ๋ก๋ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋ณผ๋ก๋์์ ํ ์ํํธ๋ก ๋นํ.
6-11์ผ์ฐจ: 6์ผ๊ฐ ํ ์ํํธ ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ํ ์ํํธ์์ ๋ฅ๋ธ๋ด๋์ผ๋ก ๋นํ.
11-13์ผ์ฐจ: 3์ผ๊ฐ ๋ฅ๋ธ๋ด๋ ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ๋ฅ๋ธ๋ด๋์์ ๋๋ธ๋ก๋ธ๋ํฌ๋ก ๋นํ.
13-16์ผ์ฐจ: 4์ผ๊ฐ ๋๋ธ๋ก๋ธ๋ํฌ ๋ฐฉ๋ฌธ.
16์ผ์ฐจ: ๋๋ธ๋ก๋ธ๋ํฌ์์ ํ์น๋ก ๋นํ.
16-18์ผ์ฐจ: 3์ผ๊ฐ ํ์น ๋ฐฉ๋ฌธ.
|
33
|
์ ๋ฝ
| 3
|
์ง์ ์์ฑ
|
์ด 9์ผ ๋์ ์ ๋ฝ 3๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ๋
ธ๋น์ฌ๋์์ 4์ผ๊ฐ ๋จธ๋ฌด๋ฅผ ๊ฒ์
๋๋ค. ๋
ธ๋น์ฌ๋์์ ์ฌํ 3-6์ผ์ฐจ์ ์งํ๋๋ ์น๊ตฌ์ ๊ฒฐํผ์์ ์ฐธ์ํ ์์ ์
๋๋ค. ํด๋ฃจ์ง๋ํฌ์นด์์ 4์ผ ๋์ ์ฌํ์ ํ ๊ฒ์
๋๋ค. ํฌ๋๋ฆฌ๊ณ ์ฐจ์์ 3์ผ๊ฐ ๋จธ๋ฌด๋ฅด๋ ค ํฉ๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋
ธ๋น์ฌ๋์ ํฌ๋๋ฆฌ๊ณ ์ฐจ, ํด๋ฃจ์ง๋ํฌ์นด์ ๋
ธ๋น์ฌ๋.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 9์ผ ๋์ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ํฌ๋๋ฆฌ๊ณ ์ฐจ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ํฌ๋๋ฆฌ๊ณ ์ฐจ์์ ๋
ธ๋น์ฌ๋๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ๋
ธ๋น์ฌ๋ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋
ธ๋น์ฌ๋์์ ํด๋ฃจ์ง๋ํฌ์นด๋ก ๋นํ.
6-9์ผ์ฐจ: 4์ผ๊ฐ ํด๋ฃจ์ง๋ํฌ์นด ๋ฐฉ๋ฌธ.
|
You plan to visit 3 cities in Europe for a total of 9 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You will stay in Novi Sad for four days. During your stay in Novi Sad, you will attend a friend's wedding, which takes place from day 3 to day 6 of your trip. You'll be traveling from Cluj-Napoca for 4 days. You'll be staying in Podgorica for 3 days.
Here are the cities that have direct flights: Novi Sad and Podgorica, Cluj-Napoca and Novi Sad.
Plan a trip to visit the three cities in 9 days using direct flights.
|
Days 1-3: Visit Podgorica for 3 days.
Day 3: Fly from Podgorica to Novi Sad.
Days 3-6: Visit Novi Sad for 4 days.
Day 6: Fly from Novi Sad to Cluj-Napoca.
Days 6-9: Visit Cluj-Napoca for 4 days.
|
๋ณ์ ์ ์:
N: ๋
ธ๋น์ฌ๋, K: ํด๋ฃจ์ง๋ํฌ์นด, P: ํฌ๋๋ฆฌ๊ณ ์ฐจ
a_N: ๋
ธ๋น์ฌ๋ ๋์ฐฉ์ผ, d_N: ๋
ธ๋น์ฌ๋ ์ถ๋ฐ์ผ
a_K: ํด๋ฃจ์ง๋ํฌ์นด ๋์ฐฉ์ผ, d_K: ํด๋ฃจ์ง๋ํฌ์นด ์ถ๋ฐ์ผ
a_P: ํฌ๋๋ฆฌ๊ณ ์ฐจ ๋์ฐฉ์ผ, d_P: ํฌ๋๋ฆฌ๊ณ ์ฐจ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_N - a_N + 1 = 4
d_K - a_K + 1 = 4
d_P - a_P + 1 = 3
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_N, d_K, d_P) - min(a_N, a_K, a_P) + 1 = 9
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[3, 6] โฉ [a_N, d_N] โ โ
์งํญํธ์ด ์๋ ๋์:
(N โ P), (K โ N)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ํฌ๋๋ฆฌ๊ณ ์ฐจ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ํฌ๋๋ฆฌ๊ณ ์ฐจ์์ ๋
ธ๋น์ฌ๋๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ๋
ธ๋น์ฌ๋ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋
ธ๋น์ฌ๋์์ ํด๋ฃจ์ง๋ํฌ์นด๋ก ๋นํ.
6-9์ผ์ฐจ: 4์ผ๊ฐ ํด๋ฃจ์ง๋ํฌ์นด ๋ฐฉ๋ฌธ.
|
34
|
์ ๋ฝ
| 3
|
์ง์ ์์ฑ
|
์ด 8์ผ ๋์ ์ ๋ฝ 3๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. 3์ผ ๋์ ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ๋ฅผ ๋ฐฉ๋ฌธํ ์์ ์
๋๋ค. ์ฒด์คํคํฌ๋ฃธ๋กํ๋ฅผ 5์ผ๊ฐ ์ฌํํ ๊ฒ์
๋๋ค. ์ฒด์คํคํฌ๋ฃธ๋กํ๊ฐ ๋ง์ง๋ง ์ฌํ์ง์์ผ๋ฉด ์ข๊ฒ ์ต๋๋ค. ๋ฐ๋ธ๋ ์ผ์์๋ 2์ผ์ ๋จธ๋ฌด๋ฅด๋ ค๊ณ ํฉ๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ์ ๋ฐ๋ธ๋ ์ผ, ์ฒด์คํคํฌ๋ฃธ๋กํ์ ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 8์ผ ๋์ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ๋ฐ๋ธ๋ ์ผ ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ๋ฐ๋ธ๋ ์ผ์์ ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ๋ก ๋นํ.
2-4์ผ์ฐจ: 3์ผ๊ฐ ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ๋
ธ๋น์ฌ๋์์ ํด๋ฃจ์ง๋ํฌ์นด๋ก ๋นํ.
4-8์ผ์ฐจ: 5์ผ๊ฐ ์ฒด์คํคํฌ๋ฃธ๋กํ ๋ฐฉ๋ฌธ.
|
You plan to visit 3 cities in Europe for a total of 8 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You will be traveling to Bratislava for 3 days. You will travel in Cesky Krumlo for five days. You would like ฤeskรฝ Krumlov to be your final destination. You will spend 2 days in Debrecen.
Here are the cities that have direct flights: Bratislava and Debrecen, Cesky Krumlov and Bratislava.
Plan a trip to visit the three cities in 8 days using direct flights.
|
Day 1-2: Visit Debrecen for 2 days.
Day 2: Fly from Debrecen to Bratislava.
Days 2-4: Visit Bratislava for 3 days.
Day 4: Fly from Bratislava to Cesky Krumlov.
Days 4-8: Visit Cesky Krumlov for 5 days.
|
๋ณ์ ์ ์:
B: ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ, C: ์ฒด์คํคํฌ๋ฃธ๋กํ, D: ๋ฐ๋ธ๋ ์ผ
a_B: ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ ๋์ฐฉ์ผ, d_B: ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ ์ถ๋ฐ์ผ
a_C: ์ฒด์คํคํฌ๋ฃธ๋กํ ๋์ฐฉ์ผ, d_C: ์ฒด์คํคํฌ๋ฃธ๋กํ ์ถ๋ฐ์ผ
a_D: ๋ฐ๋ธ๋ ์ผ ๋์ฐฉ์ผ, d_D: ๋ฐ๋ธ๋ ์ผ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_B - a_B + 1 = 3
d_C - a_C + 1 = 5
d_D - a_D + 1 = 2
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_B, d_C, d_D) - min(a_B, a_C, a_D) + 1 = 8
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
d_C = 8
์งํญํธ์ด ์๋ ๋์:
(B โ D), (C โ B)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ๋ฐ๋ธ๋ ์ผ ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ๋ฐ๋ธ๋ ์ผ์์ ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ๋ก ๋นํ.
2-4์ผ์ฐจ: 3์ผ๊ฐ ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ๋
ธ๋น์ฌ๋์์ ํด๋ฃจ์ง๋ํฌ์นด๋ก ๋นํ.
4-8์ผ์ฐจ: 5์ผ๊ฐ ์ฒด์คํคํฌ๋ฃธ๋กํ ๋ฐฉ๋ฌธ.
|
35
|
์ ๋ฝ
| 3
|
์ง์ ์์ฑ
|
์ด 8์ผ ๋์ ์ ๋ฝ 3๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์ทจ๋ฆฌํ์์ 4์ผ ๋์ ๋จธ๋ฌผ ๊ฒ์
๋๋ค.์ฌํ 5-7์ผ์ฐจ์๋ ์ทจ๋ฆฌํ์ ์๊ณ ์ถ์ต๋๋ค. 2์ผ ๋์์ ๋ฒ ๋ฅผ๋ฆฐ์ ์์ ๊ฒ์
๋๋ค. ์์ฒด์น์์ 4์ผ๊ฐ ์ฌํ์ ํ ์์ ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ฒ ๋ฅผ๋ฆฐ๊ณผ ์์ฒด์น, ์ทจ๋ฆฌํ์ ์์ฒด์น.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 8์ผ ๋์ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ๋ฒ ๋ฅผ๋ฆฐ ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ๋ฒ ๋ฅผ๋ฆฐ์์ ์์ฒด์น์ผ๋ก ๋นํ.
2-5์ผ์ฐจ: 4์ผ๊ฐ ์์ฒด์น ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ์์ฒด์น์์ ์ทจ๋ฆฌํ๋ก ๋นํ.
5-8์ผ์ฐจ: 4์ผ๊ฐ ์ทจ๋ฆฌํ ๋ฐฉ๋ฌธ.
|
You plan to visit 3 cities in Europe for a total of 8 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You will be in Zurich for 4 days. You would like to be in Zurich for days 5-7 of your trip. You will be in Berlin for 2 days. You will be in Szczecin for 4 days of your trip.
Here are the cities that have direct flights: Berlin and Szczecin, Zurich and Szczecin.
Plan a trip to visit the three cities in 8 days using direct flights.
|
Days 1-2: Visit Berlin for 2 days.
Day 2: Fly from Berlin to Szczecin.
Days 2-5: Visit Szczecin for 4 days.
Day 5: Fly from Szczecin to Zurich.
Days 5-8: Visit Zurich for 4 days.
|
๋ณ์ ์ ์:
Z: ์ทจ๋ฆฌํ, B: ๋ฒ ๋ฅผ๋ฆฐ, S: ์์ฒด์น
a_Z: ์ทจ๋ฆฌํ ๋์ฐฉ์ผ, d_Z: ์ทจ๋ฆฌํ ์ถ๋ฐ์ผ
a_B: ๋ฒ ๋ฅผ๋ฆฐ ๋์ฐฉ์ผ, d_B: ๋ฒ ๋ฅผ๋ฆฐ ์ถ๋ฐ์ผ
a_S: ์์ฒด์น ๋์ฐฉ์ผ, d_S: ์์ฒด์น ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_Z - a_Z + 1 = 4
d_B - a_B + 1 = 2
d_S - a_S + 1 = 4
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_Z, d_B, d_S) - min(a_Z, a_B, a_S) + 1 = 8
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[5, 7] โ [a_Z, d_Z]
์งํญํธ์ด ์๋ ๋์:
(B โ S), (Z โ S)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ๋ฒ ๋ฅผ๋ฆฐ ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ๋ฒ ๋ฅผ๋ฆฐ์์ ์์ฒด์น์ผ๋ก ๋นํ.
2-5์ผ์ฐจ: 4์ผ๊ฐ ์์ฒด์น ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ์์ฒด์น์์ ์ทจ๋ฆฌํ๋ก ๋นํ.
5-8์ผ์ฐจ: 4์ผ๊ฐ ์ทจ๋ฆฌํ ๋ฐฉ๋ฌธ.
|
36
|
์ ๋ฝ
| 3
|
์ง์ ์์ฑ
|
์ด 10์ผ ๋์ ์ ๋ฝ 3๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ๋ฒ ๋ฅธ์ 3์ผ ๋์ ์ฌํํ ๊ฒ์
๋๋ค. 4์ผ ๋์ ๋น์ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. 5์ผ ๋์ ๋ฒ ๋ค์น์์์ ์ฌํ์ ์ฆ๊ธฐ๋ ค ํฉ๋๋ค. 3์ผ๊ณผ 5์ผ ์ฌ์ด์ ๋ฒ ๋ค์น์์์ ์น๊ตฌ์ ์ฝ์์ ์ก์์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ฒ ๋์น์์ ๋ฒ ๋ฅธ, ๋น๊ณผ ๋ฒ ๋ค์น์.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 10์ผ ๋์ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋ฒ ๋ฅธ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋ฒ ๋ฅธ์์ ๋ฒ ๋ค์น์๋ก ๋นํ.
3-7์ผ์ฐจ: 5์ผ๊ฐ ๋ฒ ๋ค์น์ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ๋ฒ ๋ค์น์์์ ๋น์ผ๋ก ๋นํ.
7-10์ผ์ฐจ: 4์ผ๊ฐ ๋น ๋ฐฉ๋ฌธ.
|
You plan to visit 3 European cities for a total of 10 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You will be traveling to Bern for 3 days. You will be in Vienna for 4 days. You will be in Venice for 5 days. You have an appointment with a friend in Venice between days 3 and 5.
Here are the cities that have direct flights: Venice and Bern, Vienna and Venice.
Plan a trip to visit the three cities in 10 days using direct flights.
|
Days 1-3: Visit Bern for 3 days.
Day 3: Fly from Bern to Venice.
Days 3-7: Visit Venice for 5 days.
Day 7: Fly from Venice to Vienna.
Days 7-10: Visit Vienna for 4 days.
|
๋ณ์ ์ ์:
B: ๋ฒ ๋ฅธ, V: ๋น, Ve: ๋ฒ ๋ค์น์
a_B: ๋ฒ ๋ฅธ ๋์ฐฉ์ผ, d_B: ๋ฒ ๋ฅธ ์ถ๋ฐ์ผ
a_V: ๋น ๋์ฐฉ์ผ, d_V: ๋น ์ถ๋ฐ์ผ
a_Ve: ๋ฒ ๋ค์น์ ๋์ฐฉ์ผ, d_Ve: ๋ฒ ๋ค์น์ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_B - a_B + 1 = 3
d_V - a_V + 1 = 4
d_Ve - a_Ve + 1 = 5
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_B, d_V, d_Ve) - min(a_B, a_V, a_Ve) + 1 = 10
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[3, 5] โฉ [a_Ve, d_Ve] โ โ
์งํญํธ์ด ์๋ ๋์:
(Ve โ B), (V โ Ve)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋ฒ ๋ฅธ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋ฒ ๋ฅธ์์ ๋ฒ ๋ค์น์๋ก ๋นํ.
3-7์ผ์ฐจ: 5์ผ๊ฐ ๋ฒ ๋ค์น์ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ๋ฒ ๋ค์น์์์ ๋น์ผ๋ก ๋นํ.
7-10์ผ์ฐจ: 4์ผ๊ฐ ๋น ๋ฐฉ๋ฌธ.
|
37
|
์ ๋ฝ
| 4
|
์ง์ ์์ฑ
|
์ด 13์ผ ๋์ ์ ๋ฝ 4๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์ค์ฌ๋ก์์ 5์ผ ๋์ ์ฌํ์ ํ ์์ ์
๋๋ค. 3์ผ ๋์ ์ํ
๋ณด๋ฆฌ์ ๋จธ๋ฌด๋ฅด๋ ค๊ณ ํฉ๋๋ค. ์ค๋ด์ธ์์๋ 3์ผ ๋์ ๋จธ๋ฌด๋ฅด๋ ค๊ณ ํฉ๋๋ค. ํ์ฌ๋นํฌ์ 5์ผ๊ฐ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. ์ฌํ 2์ผ์ฐจ์ ํ์ฌ๋นํฌ์์ ์ผ์ด์ ๋ง๋๊ธฐ๋ก ํ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ์ํ
๋ณด๋ฆฌ์ ์ค์ฌ๋ก, ํ์ฌ๋นํฌ์ ์ํ
๋ณด๋ฆฌ, ์ค๋ด์ธ์ ์ค์ฌ๋ก.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 13์ผ ๋์ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ํ์ฌ๋นํฌ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ํ์ฌ๋นํฌ์์ ์ํ
๋ณด๋ฆฌ๋ก ๋นํ.
5-7์ผ์ฐจ: 3์ผ๊ฐ ์ํ
๋ณด๋ฆฌ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ์ํ
๋ณด๋ฆฌ์์ ์ค์ฌ๋ก๋ก ๋นํ.
7-11์ผ์ฐจ: 5์ผ๊ฐ ์ค์ฌ๋ก ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ์ค์ฌ๋ก์์ ์ค๋ด์ธ๋ก ๋นํ.
11-13์ผ์ฐจ: 3์ผ๊ฐ ์ค๋ด์ธ ๋ฐฉ๋ฌธ.
|
You plan to visit 4 European cities for a total of 13 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'll be traveling from Oslo for 5 days. You plan to stay in Gothenburg for 3 days. You also plan to stay in Odense for 3 days. You will be in Husavik for 5 days. You plan to meet your uncle in Husavik on day 2 of your trip.
Here are the cities that have direct flights: Gothenburg and Oslo, Husavik and Gothenburg, Odense and Oslo.
Plan your trip to visit four cities in 13 days using direct flights.
|
Days 1-5: Visit Husavik for 5 days.
Day 5: Fly from Husavik to Gothenburg.
Days 5-7: Visit Gothenburg for 3 days.
Day 7: Fly from Gothenburg to Oslo.
Days 7-11: Visit Oslo for 5 days.
Day 11: Fly from Oslo to Odense.
Days 11-13: Visit Odense for 3 days.
|
๋ณ์ ์ ์:
O: ์ค์ฌ๋ก, G: ์ํ
๋ณด๋ฆฌ, Od: ์ค๋ด์ธ, H: ํ์ฌ๋นํฌ
a_O: ์ค์ฌ๋ก ๋์ฐฉ์ผ, d_O: ์ค์ฌ๋ก ์ถ๋ฐ์ผ
a_G: ์ํ
๋ณด๋ฆฌ ๋์ฐฉ์ผ, d_G: ์ํ
๋ณด๋ฆฌ ์ถ๋ฐ์ผ
a_Od: ์ค๋ด์ธ ๋์ฐฉ์ผ, d_Od: ์ค๋ด์ธ ์ถ๋ฐ์ผ
a_H: ํ์ฌ๋นํฌ ๋์ฐฉ์ผ, d_H: ํ์ฌ๋นํฌ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_O - a_O + 1 = 5
d_G - a_G + 1 = 3
d_Od - a_Od + 1 = 3
d_H - a_H + 1 = 5
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_O, d_G, d_Od, d_H) - min(a_O, a_G, a_Od, a_H) + 1 = 13
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
a_H + 1 = 2
์งํญํธ์ด ์๋ ๋์:
(G โ O), (H โ G), (Od โ O)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ํ์ฌ๋นํฌ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ํ์ฌ๋นํฌ์์ ์ํ
๋ณด๋ฆฌ๋ก ๋นํ.
5-7์ผ์ฐจ: 3์ผ๊ฐ ์ํ
๋ณด๋ฆฌ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ์ํ
๋ณด๋ฆฌ์์ ์ค์ฌ๋ก๋ก ๋นํ.
7-11์ผ์ฐจ: 5์ผ๊ฐ ์ค์ฌ๋ก ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ์ค์ฌ๋ก์์ ์ค๋ด์ธ๋ก ๋นํ.
11-13์ผ์ฐจ: 3์ผ๊ฐ ์ค๋ด์ธ ๋ฐฉ๋ฌธ.
|
38
|
์ ๋ฝ
| 4
|
์ง์ ์์ฑ
|
์ด 11์ผ ๋์ ์ ๋ฝ 4๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์ฝํํ๊ฒ๊ณผ ๋ ์ด์บฌ๋นํฌ์์ ๊ฐ๊ฐ 3์ผ์ ์ฌํํ ๊ฒ์
๋๋ค. ์ผ์๋ธ๋ฆฌ์ง์ ๊ณจ์จ์ด์์ ๊ฐ๊ฐ 4์ผ์ ๋จธ๋ฌด๋ฅด๋ ค๊ณ ํฉ๋๋ค. 3-6์ผ ์ฌ์ด์ ์ผ์๋ธ๋ฆฌ์ง์์ ๋ฎค์ง์ปฌ์ ๋ณด๋ ค๊ณ ํฉ๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ์ผ์๋ธ๋ฆฌ์ง์ ๊ณจ์จ์ด, ๋ ์ด์บฌ๋นํฌ์ ๊ณจ์จ์ด, ์ฝํํ๊ฒ๊ณผ ์ผ์๋ธ๋ฆฌ์ง.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 11์ผ ๋์ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ์ฝํํ๊ฒ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ์ฝํํ๊ฒ์์ ์ผ์๋ธ๋ฆฌ์ง๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ์ผ์๋ธ๋ฆฌ์ง ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์ผ์๋ธ๋ฆฌ์ง์์ ๊ณจ์จ์ด๋ก ๋นํ.
6-9์ผ์ฐจ: 4์ผ๊ฐ ๊ณจ์จ์ด ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ๊ณจ์จ์ด์์ ๋ ์ด์บฌ๋นํฌ๋ก ๋นํ.
9-11์ผ์ฐจ: 3์ผ๊ฐ ๋ ์ด์บฌ๋นํฌ ๋ฐฉ๋ฌธ.
|
You plan to visit 4 European cities for a total of 12 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You will spend 3 days each in Copenhagen and Reykjavik. You want to spend 4 days each in Cambridge and Galway. You want to see a musical in Cambridge between days 3-6.
Here are the cities that have direct flights: Cambridge and Galway, Reykjavik and Galway, Copenhagen and Cambridge.
Plan a trip to visit four cities in 11 days using direct flights.
|
Days 1-3: Visit Copenhagen for 3 days.
Day 3: Fly from Copenhagen to Cambridge.
Days 3-6: Visit Cambridge for 4 days.
Day 6: Fly from Cambridge to Galway.
Days 6-9: Visit Galway for 4 days.
Day 9: Fly from Galway to Reykjavik.
Days 9-11: Visit Reykjavik for 3 days.
|
๋ณ์ ์ ์:
C: ์ฝํํ๊ฒ, R: ๋ ์ด์บฌ๋นํฌ, K: ์ผ์๋ธ๋ฆฌ์ง, G: ๊ณจ์จ์ด
a_C: ์ฝํํ๊ฒ ๋์ฐฉ์ผ, d_C: ์ฝํํ๊ฒ ์ถ๋ฐ์ผ
a_R: ๋ ์ด์บฌ๋นํฌ ๋์ฐฉ์ผ, d_R: ๋ ์ด์บฌ๋นํฌ ์ถ๋ฐ์ผ
a_K: ์ผ์๋ธ๋ฆฌ์ง ๋์ฐฉ์ผ, d_K: ์ผ์๋ธ๋ฆฌ์ง ์ถ๋ฐ์ผ
a_G: ๊ณจ์จ์ด ๋์ฐฉ์ผ, d_G: ๊ณจ์จ์ด ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_C - a_C + 1 = 3
d_R - a_R + 1 = 3
d_K - a_K + 1 = 4
d_G - a_G + 1 = 4
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_C, d_R, d_K, d_G) - min(a_C, a_R, a_K, a_G) + 1 = 11
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[3, 6] โฉ [a_K, d_K] โ โ
์งํญํธ์ด ์๋ ๋์:
(K โ G), (R โ G), (C โ K)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ์ฝํํ๊ฒ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ์ฝํํ๊ฒ์์ ์ผ์๋ธ๋ฆฌ์ง๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ์ผ์๋ธ๋ฆฌ์ง ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์ผ์๋ธ๋ฆฌ์ง์์ ๊ณจ์จ์ด๋ก ๋นํ.
6-9์ผ์ฐจ: 4์ผ๊ฐ ๊ณจ์จ์ด ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ๊ณจ์จ์ด์์ ๋ ์ด์บฌ๋นํฌ๋ก ๋นํ.
9-11์ผ์ฐจ: 3์ผ๊ฐ ๋ ์ด์บฌ๋นํฌ ๋ฐฉ๋ฌธ.
|
39
|
์ ๋ฝ
| 4
|
์ง์ ์์ฑ
|
์ด 13์ผ ๋์ ์ ๋ฝ 4๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์ธ๋น์ผ์์ 3์ผ์ ๋ณด๋ผ ๊ฒ์
๋๋ค. ๋๋ธ๋ฆฐ์ 4์ผ ๋์ ๋ฐฉ๋ฌธํ๊ณ ์ถ์ต๋๋ค. ํ๋ฆฌ๋ฅผ 7์ผ ๋์ ๋ฐฉ๋ฌธํ ์์ ์
๋๋ค. 8-11์ผ ์ฌ์ด์ ํ๋ฆฌ์์ ๋ฐ๋ฌผ๊ด ํฌ์ด๋ฅผ ์ ์ฒญํด๋์์ต๋๋ค. 2์ผ ๋์ ์๊ฐ๋ฅด๋ธ์ ์์ ๊ฒ์
๋๋ค. ์๊ฐ๋ฅด๋ธ์ ์ฌํ 4์ผ์ฐจ์ ๋์ฐฉํ ์์ ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ์๊ฐ๋ฅด๋ธ์ ์ธ๋น์ผ, ๋๋ธ๋ฆฐ๊ณผ ์๊ฐ๋ฅด๋ธ, ํ๋ฆฌ์ ์ธ๋น์ผ, ํ๋ฆฌ์ ์๊ฐ๋ฅด๋ธ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 13์ผ ๋์ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ๋๋ธ๋ฆฐ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ๋๋ธ๋ฆฐ์์ ์๊ฐ๋ฅด๋ธ๋ก ๋นํ.
4-5์ผ์ฐจ: 2์ผ๊ฐ ์๊ฐ๋ฅด๋ธ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ์๊ฐ๋ฅด๋ธ์์ ์ธ๋น์ผ๋ก ๋นํ.
5-7์ผ์ฐจ: 3์ผ๊ฐ ์ธ๋น์ผ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ์ธ๋น์ผ์์ ํ๋ฆฌ๋ก ๋นํ.
7-13์ผ์ฐจ: 7์ผ๊ฐ ํ๋ฆฌ ๋ฐฉ๋ฌธ.
|
You plan to visit 4 cities in Europe for a total of 13 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'll spend 3 days in Seville. You want to visit Dublin for 4 days. You'll be visiting Paris for 7 days. You've signed up for a museum tour in Paris between days 8-11. You'll be in the Algarve for 2 days. You will arrive in the Algarve on day 4 of your trip.
Here are the cities that have direct flights: Algarve and Seville, Dublin and Algarve, Paris and Seville, Paris and Algarve.
Plan your trip to visit four cities in 13 days using direct flights.
|
Days 1-4: Visit Dublin for 4 days.
Day 4: Fly from Dublin to Algarve.
Days 4-5: Visit Algarve for 2 days.
Day 5: Fly from Algarve to Seville.
Days 5-7: Visit Seville for 3 days.
Day 7: Fly from Seville to Paris.
Days 7-13: Visit Paris for 7 days.
|
๋ณ์ ์ ์:
S: ์ธ๋น์ผ, D: ๋๋ธ๋ฆฐ, P: ํ๋ฆฌ, A: ์๊ฐ๋ฅด๋ธ
a_S: ์ธ๋น์ผ ๋์ฐฉ์ผ, d_S: ์ธ๋น์ผ ์ถ๋ฐ์ผ
a_D: ๋๋ธ๋ฆฐ ๋์ฐฉ์ผ, d_D: ๋๋ธ๋ฆฐ ์ถ๋ฐ์ผ
a_P: ํ๋ฆฌ ๋์ฐฉ์ผ, d_P: ํ๋ฆฌ ์ถ๋ฐ์ผ
a_A: ์๊ฐ๋ฅด๋ธ ๋์ฐฉ์ผ, d_A: ์๊ฐ๋ฅด๋ธ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_S - a_S + 1 = 3
d_D - a_D + 1 = 4
d_P - a_P + 1 = 7
d_A - a_A + 1 = 2
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_S, d_D, d_P, d_A) - min(a_S, a_D, a_P, a_A) + 1 = 13
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[8, 11] โฉ [a_P, d_P] โ โ
a_A = 4
์งํญํธ์ด ์๋ ๋์:
(A โ S), (D โ A), (P โ S), (P โ A)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ๋๋ธ๋ฆฐ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ๋๋ธ๋ฆฐ์์ ์๊ฐ๋ฅด๋ธ๋ก ๋นํ.
4-5์ผ์ฐจ: 2์ผ๊ฐ ์๊ฐ๋ฅด๋ธ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ์๊ฐ๋ฅด๋ธ์์ ์ธ๋น์ผ๋ก ๋นํ.
5-7์ผ์ฐจ: 3์ผ๊ฐ ์ธ๋น์ผ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ์ธ๋น์ผ์์ ํ๋ฆฌ๋ก ๋นํ.
7-13์ผ์ฐจ: 7์ผ๊ฐ ํ๋ฆฌ ๋ฐฉ๋ฌธ.
|
40
|
์ ๋ฝ
| 4
|
์ง์ ์์ฑ
|
์ด 14์ผ ๋์ ์ ๋ฝ 4๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. 3์ผ ๋์ ๋กํ
๋ฅด๋ด์์ ๋จธ๋ฌผ ์์ ์
๋๋ค. ์ฌํ 3-4์ผ์ฐจ์ ๋กํ
๋ฅด๋ด์ ์๋ ๋ ์คํ ๋์ ์์ฝํด๋์์ต๋๋ค. ์คํธ๋ผ์ค๋ถ๋ฅด์์ 7์ผ์ ์ฌํํ๋ ค๊ณ ํฉ๋๋ค. ์ค๋ฅดํ์ค์ 2์ผ ๋์ ๋จธ๋ฌผ ๊ฒ์
๋๋ค. ์ฌํ 2์ผ์ฐจ์ ์ค๋ฅดํ์ค์์ ์น๊ตฌ๋ฅผ ๋ง๋ ๋ํํ๊ธฐ๋ก ํ์ต๋๋ค. ๋ธ๋คผ์
์์๋ 5์ผ ๋์ ๋จธ๋ฌด๋ฅด๋ ค๊ณ ํฉ๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋กํ
๋ฅด๋ด๊ณผ ๋ธ๋คผ์
, ์ค๋ฅดํ์ค์ ๋กํ
๋ฅด๋ด, ์ค๋ฅดํ์ค์ ๋ธ๋คผ์
, ์คํธ๋ผ์ค๋ถ๋ฅด์ ๋ธ๋คผ์
.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 14์ผ ๋์ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ์ค๋ฅดํ์ค ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ์ค๋ฅดํ์ค์์ ๋กํ
๋ฅด๋ด์ผ๋ก ๋นํ.
2-4์ผ์ฐจ: 3์ผ๊ฐ ๋กํ
๋ฅด๋ด ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ๋กํ
๋ฅด๋ด์์ ๋ธ๋คผ์
๋ก ๋นํ.
4-8์ผ์ฐจ: 5์ผ๊ฐ ๋ธ๋คผ์
๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ๋ธ๋คผ์
์์ ์คํธ๋ผ์ค๋ถ๋ฅด๋ก ๋นํ.
8-14์ผ์ฐจ: 7์ผ๊ฐ ์คํธ๋ผ์ค๋ถ๋ฅด ๋ฐฉ๋ฌธ.
|
You plan to visit 4 cities in Europe for a total of 14 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You plan to stay in Rotterdam for 3 days. You have reservations for a restaurant in Rotterdam on days 3-4 of your trip. You plan to spend 7 days traveling in Strasbourg. You'll be staying in Aarhus for 2 days. You've arranged to meet a friend in Aarhus on Day 2 of your trip to accompany you. You plan to stay in Brussels for 5 days.
Here are the cities that have direct flights: Rotterdam and Brussels, Aarhus and Rotterdam, Aarhus and Brussels, Strasbourg and Brussels.
Plan a trip to visit four cities in 14 days using direct flights.
|
Day 1-2: Visit Aarhus for 2 days.
Day 2: Fly from Aarhus to Rotterdam.
Days 2-4: Visit Rotterdam for 3 days.
Day 4: Fly from Rotterdam to Brussels.
Days 4-8: Visit Brussels for 5 days.
Day 8: Fly from Brussels to Strasbourg.
Days 8-14: Visit Strasbourg for 7 days.
|
๋ณ์ ์ ์:
R: ๋กํ
๋ฅด๋ด, S: ์คํธ๋ผ์ค๋ถ๋ฅด, A: ์ค๋ฅดํ์ค, B: ๋ธ๋คผ์
a_R: ๋กํ
๋ฅด๋ด ๋์ฐฉ์ผ, d_R: ๋กํ
๋ฅด๋ด ์ถ๋ฐ์ผ
a_S: ์คํธ๋ผ์ค๋ถ๋ฅด ๋์ฐฉ์ผ, d_S: ์คํธ๋ผ์ค๋ถ๋ฅด ์ถ๋ฐ์ผ
a_A: ์ค๋ฅดํ์ค ๋์ฐฉ์ผ, d_A: ์ค๋ฅดํ์ค ์ถ๋ฐ์ผ
a_B: ๋ธ๋คผ์
๋์ฐฉ์ผ, d_B: ๋ธ๋คผ์
์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_R - a_R + 1 = 3
d_S - a_S + 1 = 7
d_A - a_A + 1 = 2
d_B - a_B + 1 = 5
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_R, d_S, d_A, d_B) - min(a_R, a_S, a_A, a_B) + 1 = 14
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
{3, 4} โฉ [a_R, d_R] โ โ
a_A โค 2 โค d_A
์งํญํธ์ด ์๋ ๋์:
(R โ B), (A โ R), (A โ B), (S โ B)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ์ค๋ฅดํ์ค ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ์ค๋ฅดํ์ค์์ ๋กํ
๋ฅด๋ด์ผ๋ก ๋นํ.
2-4์ผ์ฐจ: 3์ผ๊ฐ ๋กํ
๋ฅด๋ด ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ๋กํ
๋ฅด๋ด์์ ๋ธ๋คผ์
๋ก ๋นํ.
4-8์ผ์ฐจ: 5์ผ๊ฐ ๋ธ๋คผ์
๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ๋ธ๋คผ์
์์ ์คํธ๋ผ์ค๋ถ๋ฅด๋ก ๋นํ.
8-14์ผ์ฐจ: 7์ผ๊ฐ ์คํธ๋ผ์ค๋ถ๋ฅด ๋ฐฉ๋ฌธ.
|
41
|
์ ๋ฝ
| 5
|
์ง์ ์์ฑ
|
์ด 14์ผ ๋์ ์ ๋ฝ 5๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. 6์ผ ๋์ ๋ถ์ฟ ๋ ์ํฐ์์ ์ฌํ์ ํ๊ณ ์ถ์ต๋๋ค. ์ฌํ 7-12์ผ์ฐจ์๋ ๋ถ์ฟ ๋ ์ํฐ์ ์๋ ์ด๋ชจ์ ์ง์์ ๋จธ๋ฌด๋ฅด๋ ค๊ณ ํฉ๋๋ค. 4์ผ๊ฐ ํ์ ์์ ๋จธ๋ฌผ ๊ฒ์
๋๋ค. ์ฌํ 2์ผ์ฐจ์ ํ์ ์์ ์งํ๋๋ ์์กฐ์ฅ ํฌ์ด๋ฅผ ์์ฝํด๋์์ต๋๋ค. 3์ผ ๋์ ํค์๋์ฐ์ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. ์ฌํ์ ๋ง์ง๋ง ํ์ ์ง๊ฐ ํค์๋์ฐ์์ผ๋ฉด ์ข๊ฒ ์ต๋๋ค. ๋ฐ๋ธ๋ ์ผ์๋ 2์ผ๋ง ๋จธ๋ฌด๋ฅผ ๊ฒ์
๋๋ค. 3์ผ ๋์ ์ธ์ค๋ถ๋ฅดํฌ์ ๋จธ๋ฌด๋ ค๊ณ ํฉ๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ์ธ์ค๋ธ๋ฃจํฌ์ ํค์๋์ฐ, ์ธ์ค๋ถ๋ฅดํฌ์ ๋ฐ๋ธ๋ ์ผ, ํ์ ๊ณผ ๋ฐ๋ธ๋ ์ผ, ํ์ ๊ณผ ์ธ์ค๋ถ๋ฅดํฌ, ํค์๋์ฐ์ ๋ถ์ฟ ๋ ์ํฐ, ๋ถ์ฟ ๋ ์ํฐ์ ๋ฐ๋ธ๋ ์ผ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 14์ผ ๋์ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ํ์ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ํ์ ์์ ์ธ์ค๋ถ๋ฅดํฌ๋ก ๋นํ.
4-6์ผ์ฐจ: 3์ผ๊ฐ ์ธ์ค๋ถ๋ฅดํฌ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์ธ์คํฌ๋ธํฌ์์ ๋ฐ๋ธ๋ ์ผ๋ก ๋นํ.
6-7์ผ์ฐจ: 2์ผ๊ฐ ๋ฐ๋ธ๋ ์ผ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ๋ฐ๋ธ๋ ์ผ์์ ๋ถ์ฟ ๋ ์ํฐ๋ก ๋นํ.
7-12์ผ์ฐจ: 6์ผ๊ฐ ๋ถ์ฟ ๋ ์ํฐ ๋ฐฉ๋ฌธ.
12์ผ์ฐจ: ๋ถ์ฟ ๋ ์ํฐ์์ ํค์๋์ฐ๋ก ๋นํ.
12-14์ผ์ฐจ: 3์ผ๊ฐ ํค์๋์ฐ ๋ฐฉ๋ฌธ.
|
You plan to visit 5 cities in Europe for a total of 14 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'd like to spend 6 days in Bucharest. You'd like to stay at your aunt's house in Bucharest on days 7-12 of your trip. You'll be in Plzen for 4 days. You've booked a brewery tour in Plzen on day 2 of your trip. You'll be in Kishinev for 3 days. You'd like Kishinev to be the last stop on your trip. You will only be in Debresen for 2 days. You'd like to be in Innsbruck for 3 days.
Here are the cities that have direct flights: Innsbruck and Kishinev, Innsbruck and Debresen, Plzen and Debresen, Plzen and Innsbruck, Kishinev and Bucharest, Bucharest and Debresen.
Plan a trip to visit five cities in 14 days with direct flights.
|
Days 1-4: Visit Plzen for 4 days.
Day 4: Fly from Plzen to Innsbruck.
Days 4-6: Visit Innsbruck for 3 days.
Day 6: Fly from Innsbruck to Debresen.
Days 6-7: Visit Debresen for 2 days.
Day 7: Fly from Debresen to Bucharest.
Days 7-12: Visit Bucharest for 6 days.
Day 12: Fly from Bucharest to Kishinev.
Days 12-14: Visit Kishinev for 3 days.
|
๋ณ์ ์ ์:
B: ๋ถ์ฟ ๋ ์ํฐ, P: ํ์ , K: ํค์๋์ฐ, D: ๋ฐ๋ธ๋ ์ผ, I: ์ธ์ค๋ถ๋ฅดํฌ
a_B: ๋ถ์ฟ ๋ ์ํฐ ๋์ฐฉ์ผ, d_B: ๋ถ์ฟ ๋ ์ํฐ ์ถ๋ฐ์ผ
a_P: ํ์ ๋์ฐฉ์ผ, d_P: ํ์ ์ถ๋ฐ์ผ
a_K: ํค์๋์ฐ ๋์ฐฉ์ผ, d_K: ํค์๋์ฐ ์ถ๋ฐ์ผ
a_D: ๋ฐ๋ธ๋ ์ผ ๋์ฐฉ์ผ, d_D: ๋ฐ๋ธ๋ ์ผ ์ถ๋ฐ์ผ
a_I: ์ธ์ค๋ถ๋ฅดํฌ ๋์ฐฉ์ผ, d_I: ์ธ์ค๋ถ๋ฅดํฌ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_B - a_B + 1 = 6
d_P - a_P + 1 = 4
d_K - a_K + 1 = 3
d_D - a_D + 1 = 2
d_I - a_I + 1 = 3
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_B, d_P, d_K, d_D, d_I) - min(a_B, a_P, a_K, a_D, a_I) + 1 = 14
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[7, 12] โ [a_B, d_B]
a_P โค 2 โค d_P
d_K = 14
์งํญํธ์ด ์๋ ๋์:
(I โ K), (I โ D), (P โ D), (P โ I), (K โ B), (B โ D)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ํ์ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ํ์ ์์ ์ธ์ค๋ถ๋ฅดํฌ๋ก ๋นํ.
4-6์ผ์ฐจ: 3์ผ๊ฐ ์ธ์ค๋ถ๋ฅดํฌ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์ธ์คํฌ๋ธํฌ์์ ๋ฐ๋ธ๋ ์ผ๋ก ๋นํ.
6-7์ผ์ฐจ: 2์ผ๊ฐ ๋ฐ๋ธ๋ ์ผ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ๋ฐ๋ธ๋ ์ผ์์ ๋ถ์ฟ ๋ ์ํฐ๋ก ๋นํ.
7-12์ผ์ฐจ: 6์ผ๊ฐ ๋ถ์ฟ ๋ ์ํฐ ๋ฐฉ๋ฌธ.
12์ผ์ฐจ: ๋ถ์ฟ ๋ ์ํฐ์์ ํค์๋์ฐ๋ก ๋นํ.
12-14์ผ์ฐจ: 3์ผ๊ฐ ํค์๋์ฐ ๋ฐฉ๋ฌธ.
|
42
|
์ ๋ฝ
| 5
|
์ง์ ์์ฑ
|
์ด 13์ผ ๋์ ์ ๋ฝ 5๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์ค์ฝํ์์ 3์ผ์ ๋ณด๋ผ ๊ฒ์
๋๋ค. ์ํ
๋ค์์ 5์ผ๊ฐ ๋จธ๋ฌด๋ฅผ ๊ฒ์
๋๋ค. 3์ผ์ ์ํ
๋ค ์ผ๊ฒฝ ํฌ์ด๋ฅผ ๊ฐ๊ณ ์ถ์ต๋๋ค. 2์ผ ๋์ ํฐ๋ผ๋์ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. ๋ถ์ฟ ๋ ์ํฐ์์ 4์ผ์ ์ฌํํ๊ณ ์ ํฉ๋๋ค. 3์ผ๊ฐ ์ํผ์์ ์์ ์์ ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ์ํผ์์ ์ค์ฝํ, ์ค์ฝํ์ ํฐ๋ผ๋, ๋ถ์ฟ ๋ ์ํฐ์ ์ํผ์, ํฐ๋ผ๋์ ์ํ
๋ค.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 13์ผ ๋์ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ์ํ
๋ค ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ์ํ
๋ค์์ ํฐ๋ผ๋๋ก ๋นํ.
5-6์ผ์ฐจ: 2์ผ๊ฐ ํฐ๋ผ๋ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ํฐ๋ผ๋์์ ์ค์ฝํ๋ก ๋นํ.
6-8์ผ์ฐจ: 3์ผ๊ฐ ์ค์ฝํ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ์ค์ฝํ์์ ์ํผ์๋ก ๋นํ.
8-10์ผ์ฐจ: 3์ผ๊ฐ ์ํผ์ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ์ํผ์์์ ๋ถ์ฟ ๋ ์ํฐ๋ก ๋นํ.
10-13์ผ์ฐจ: 4์ผ๊ฐ ๋ถ์ฟ ๋ ์ํฐ ๋ฐฉ๋ฌธ.
|
You plan to visit 5 cities in Europe for a total of 13 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'll spend 3 days in Skopje. You'll be in Athens for 5 days. You want to go on a night tour of Athens on day 3. You'll be in Tirana for 2 days. You'd like to spend 4 days in Bucharest. You'll be in Sofia for 3 days.
Here are the cities that have direct flights: Sofia and Skopje, Skopje and Tirana, Bucharest and Sofia, Tirana and Athens.
Plan a trip to visit five cities in 13 days using direct flights.
|
Days 1-5: Visit Athens for 5 days.
Day 5: Fly from Athens to Tirana.
Days 5-6: Visit Tirana for 2 days.
Day 6: Fly from Tirana to Skopje.
Days 6-8: Visit Skopje for 3 days.
Day 8: Fly from Skopje to Sofia.
Days 8-10: Visit Sofia for 3 days.
Day 10: Fly from Sofia to Bucharest.
Days 10-13: Visit Bucharest for 4 days.
|
๋ณ์ ์ ์:
S: ์ค์ฝํ, A: ์ํ
๋ค, T: ํฐ๋ผ๋, B: ๋ถ์ฟ ๋ ์ํฐ, F: ์ํผ์
a_S: ์ค์ฝํ ๋์ฐฉ์ผ, d_S: ์ค์ฝํ ์ถ๋ฐ์ผ
a_A: ์ํ
๋ค ๋์ฐฉ์ผ, d_A: ์ํ
๋ค ์ถ๋ฐ์ผ
a_T: ํฐ๋ผ๋ ๋์ฐฉ์ผ, d_T: ํฐ๋ผ๋ ์ถ๋ฐ์ผ
a_B: ๋ถ์ฟ ๋ ์ํฐ ๋์ฐฉ์ผ, d_B: ๋ถ์ฟ ๋ ์ํฐ ์ถ๋ฐ์ผ
a_F: ์ํผ์ ๋์ฐฉ์ผ, d_F: ์ํผ์ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_S - a_S + 1 = 3
d_A - a_A + 1 = 5
d_T - a_T + 1 = 2
d_B - a_B + 1 = 4
d_F - a_F + 1 = 3
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_S, d_A, d_T, d_B, d_F) - min(a_S, a_A, a_T, a_B, a_F) + 1 = 13
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
a_A โค 3 โค d_A
์งํญํธ์ด ์๋ ๋์:
(F โ S), (S โ T), (B โ F), (T โ A)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ์ํ
๋ค ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ์ํ
๋ค์์ ํฐ๋ผ๋๋ก ๋นํ.
5-6์ผ์ฐจ: 2์ผ๊ฐ ํฐ๋ผ๋ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ํฐ๋ผ๋์์ ์ค์ฝํ๋ก ๋นํ.
6-8์ผ์ฐจ: 3์ผ๊ฐ ์ค์ฝํ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ์ค์ฝํ์์ ์ํผ์๋ก ๋นํ.
8-10์ผ์ฐจ: 3์ผ๊ฐ ์ํผ์ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ์ํผ์์์ ๋ถ์ฟ ๋ ์ํฐ๋ก ๋นํ.
10-13์ผ์ฐจ: 4์ผ๊ฐ ๋ถ์ฟ ๋ ์ํฐ ๋ฐฉ๋ฌธ.
|
43
|
์ ๋ฝ
| 5
|
์ง์ ์์ฑ
|
์ด 16์ผ ๋์ ์ ๋ฝ 5๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. 2์ผ๊ฐ ๋ฅ๋ธ๋ด๋๋ฅผ ๊ตฌ๊ฒฝํ ๊ฒ์
๋๋ค. ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ์์ 3์ผ์ ๋จธ๋ฌด๋ฅด๋ ค๊ณ ํฉ๋๋ค. 5์ผ ๋์ ๋ถ๋คํ์คํธ์์ ์ฌํ์ ์ฆ๊ธธ ๊ฒ์
๋๋ค. 6-8์ผ ์ฌ์ด์ ๋ถ๋คํ์คํธ์์ ์ ํ์ ํ๋ ์น๊ตฌ๋ฅผ ๋ง๋๊ธฐ๋ก ํ์ต๋๋ค. ํ๋ผํ์์ 6์ผ์ ๋จธ๋ฌผ ๊ฒ์
๋๋ค. ์ฌํ 11-16์ผ์ฐจ์ ๋จธ๋ฌผ ํ์ธ๋ฏผ๋ฐ์ ํ๋ผํ์์ ์์ฝํ์ต๋๋ค. 4์ผ๊ฐ ๋น์์ ๋จธ๋ฌผ ์์ ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ํ๋ผํ์ ๋ถ๋คํ์คํธ, ํ๋ผํ์ ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ, ํ๋ผํ์ ๋น, ๋น๊ณผ ๋ถ๋คํ์คํธ, ๋น๊ณผ ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ, ๋ฅ๋ธ๋ด๋์ ๋น, ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ์ ๋ถ๋คํ์คํธ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 16์ผ ๋์ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ๋ฅ๋ธ๋ด๋ ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ๋ฅ๋ธ๋ด๋์์ ๋น์ผ๋ก ๋นํ.
2-5์ผ์ฐจ: 4์ผ๊ฐ ๋น ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋น์์ ๋ถ๋คํ์คํธ๋ก ๋นํ.
5-9์ผ์ฐจ: 5์ผ๊ฐ ๋ถ๋คํ์คํธ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ๋ถ๋คํ์คํธ์์ ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ๋ก ๋นํ.
9-11์ผ์ฐจ: 3์ผ๊ฐ ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ์์ ํ๋ผํ๋ก ๋นํ.
11-16์ผ์ฐจ: 6์ผ๊ฐ ํ๋ผํ ๋ฐฉ๋ฌธ.
|
You plan to visit 5 cities in Europe for a total of 16 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You will spend 2 days in Ljubljana. You're going to spend 3 days in Bratislava. You're going to spend 5 days in Budapest. You're going to meet a friend who's studying abroad in Budapest between days 6 and 8. You'll spend 6 days in Prague. You've booked a bed and breakfast in Prague for days 11-16 of your trip. You'll spend 4 days in Vienna.
Here are the cities that have direct flights: Prague and Budapest, Prague and Bratislava, Prague and Vienna, Vienna and Budapest, Vienna and Bratislava, Ljubljana and Vienna, Bratislava and Budapest.
Plan a trip to visit five cities in 16 days with direct flights.
|
Day 1-2: Visit Ljubljana for 2 days.
Day 2: Fly from Ljubljana to Vienna.
Days 2-5: Visit Vienna for 4 days.
Day 5: Fly from Vienna to Budapest.
Days 5-9: Visit Budapest for 5 days.
Day 9: Fly from Budapest to Bratislava.
Days 9-11: Visit Bratislava for 3 days.
Day 11: Fly from Bratislava to Prague.
Days 11-16: Visit Prague for 6 days.
|
๋ณ์ ์ ์:
L: ๋ฅ๋ธ๋ด๋, B: ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ, P: ๋ถ๋คํ์คํธ, R: ํ๋ผํ, V: ๋น
a_L: ๋ฅ๋ธ๋ด๋ ๋์ฐฉ์ผ, d_L: ๋ฅ๋ธ๋ด๋ ์ถ๋ฐ์ผ
a_B: ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ ๋์ฐฉ์ผ, d_B: ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ ์ถ๋ฐ์ผ
a_P: ๋ถ๋คํ์คํธ ๋์ฐฉ์ผ, d_P: ๋ถ๋คํ์คํธ ์ถ๋ฐ์ผ
a_R: ํ๋ผํ ๋์ฐฉ์ผ, d_R: ํ๋ผํ ์ถ๋ฐ์ผ
a_V: ๋น ๋์ฐฉ์ผ, d_V: ๋น ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_L - a_L + 1 = 2
d_B - a_B + 1 = 3
d_P - a_P + 1 = 5
d_R - a_R + 1 = 6
d_V - a_V + 1 = 4
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_L, d_B, d_P, d_R, d_V) - min(a_L, a_B, a_P, a_R, a_V) + 1 = 16
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[6, 8] โฉ [a_P, d_P] โ โ
[11, 16] โ [a_R, d_R]
์งํญํธ์ด ์๋ ๋์:
(R โ P), (R โ B), (R โ V), (V โ P), (V โ B), (L โ V), (B โ P)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ๋ฅ๋ธ๋ด๋ ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ๋ฅ๋ธ๋ด๋์์ ๋น์ผ๋ก ๋นํ.
2-5์ผ์ฐจ: 4์ผ๊ฐ ๋น ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋น์์ ๋ถ๋คํ์คํธ๋ก ๋นํ.
5-9์ผ์ฐจ: 5์ผ๊ฐ ๋ถ๋คํ์คํธ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ๋ถ๋คํ์คํธ์์ ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ๋ก ๋นํ.
9-11์ผ์ฐจ: 3์ผ๊ฐ ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ์์ ํ๋ผํ๋ก ๋นํ.
11-16์ผ์ฐจ: 6์ผ๊ฐ ํ๋ผํ ๋ฐฉ๋ฌธ.
|
44
|
์ ๋ฝ
| 5
|
์ง์ ์์ฑ
|
์ด 17์ผ ๋์ ์ ๋ฝ 5๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ๋น๋ด์ค์์ 4์ผ์ ๋ณด๋ผ ๊ฒ์
๋๋ค. ํค์ด์ฐ์์ 3์ผ์ ๋ณด๋ผ ์์ ์
๋๋ค. ํค์ด์ฐ์์ ์ฌํ์ ์์ํ๋ ค ํฉ๋๋ค. 3์ผ ๋์์ ๋ฆฌ๊ฐ์ ์์ ๊ฒ์
๋๋ค. 10์ผ๊ณผ 12์ผ ์ฌ์ด์ ์น๊ตฌ์ ๋ฆฌ๊ฐ ์ฌํ์ ๊ฐ์ด ํ๋ ค๊ณ ํฉ๋๋ค. ๋ฏผ์คํฌ์์ 5์ผ๊ฐ ๋จธ๋ฌด๋ฅผ ๊ฒ์
๋๋ค. 3์ผ๊ณผ 4์ผ ์ฌ์ด์ ๋ฏผ์คํฌ์ ์ฌ๋ ์น๊ตฌ๋ค ์ง๋ค์ด๋ฅผ ์ฐธ์ํ ๊ฒ์
๋๋ค. 6์ผ ๋์ ํ๋ฆฐ์ ๋จธ๋ฌด๋ฅด๊ณ ์ถ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ํค์ด์ฐ์ ๋ฆฌ๊ฐ, ๋ฏผ์คํฌ์ ํค์ด์ฐ, ๋น๋ด์ค์ ํค์ด์ฐ, ๋น๋ด์ค์ ๋ฏผ์คํฌ, ๋น๋ด์ค์ ํ๋ฆฐ, ๋ฆฌ๊ฐ์ ๋น๋ด์ค, ํ๋ฆฐ๊ณผ ๋ฆฌ๊ฐ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 17์ผ ๋์ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ํค์ด์ฐ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ํค์ด์ฐ์์ ๋ฏผ์คํฌ๋ก ๋นํ.
3-7์ผ์ฐจ: 5์ผ๊ฐ ๋ฏผ์คํฌ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ๋ฏผ์คํฌ์์ ๋น๋ด์ค๋ก ๋นํ.
7-10์ผ์ฐจ: 4์ผ๊ฐ ๋น๋ด์ค ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ๋น๋ด์ค์์ ๋ฆฌ๊ฐ๋ก ๋นํ.
10-12์ผ์ฐจ: 3์ผ๊ฐ ๋ฆฌ๊ฐ ๋ฐฉ๋ฌธ.
12์ผ์ฐจ: ๋ฆฌ๊ฐ์์ ํ๋ฆฐ์ผ๋ก ๋นํ.
12-17์ผ์ฐจ: 6์ผ๊ฐ ํ๋ฆฐ ๋ฐฉ๋ฌธ.
|
You plan to visit 5 cities in Europe for a total of 17 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'll spend 4 days in Vilnius. You're going to spend 3 days in Kyiv. You'll be in Riga for 3 days. You're joining a friend for a trip to Riga between the 10th and 12th. You'll be in Minsk for 5 days. Between the 3rd and 4th, you'll be attending a housewarming party for a friend in Minsk. You'd like to stay in Tallinn for 6 days.
Here are the cities that have direct flights: Kyiv and Riga, Minsk and Kyiv, Vilnius and Kyiv, Vilnius and Minsk, Vilnius and Tallinn, Riga and Vilnius, Tallinn and Riga.
Plan a trip to visit five cities in 17 days with direct flights.
|
Days 1-3: Visit Kyiv for 3 days.
Day 3: Fly from Kyiv to Minsk.
Days 3-7: Visit Minsk for 5 days.
Day 7: Fly from Minsk to Vilnius.
Days 7-10: Visit Vilnius for 4 days.
Day 10: Fly from Vilnius to Riga.
Days 10-12: Visit Riga for 3 days.
Day 12: Fly from Riga to Tallinn.
Days 12-17: Visit Tallinn for 6 days.
|
๋ณ์ ์ ์:
V: ๋น๋ด์ค, K: ํค์ด์ฐ, R: ๋ฆฌ๊ฐ, M: ๋ฏผ์คํฌ, T: ํ๋ฆฐ
a_V: ๋น๋ด์ค ๋์ฐฉ์ผ, d_V: ๋น๋ด์ค ์ถ๋ฐ์ผ
a_K: ํค์ด์ฐ ๋์ฐฉ์ผ, d_K: ํค์ด์ฐ ์ถ๋ฐ์ผ
a_R: ๋ฆฌ๊ฐ ๋์ฐฉ์ผ, d_R: ๋ฆฌ๊ฐ ์ถ๋ฐ์ผ
a_M: ๋ฏผ์คํฌ ๋์ฐฉ์ผ, d_M: ๋ฏผ์คํฌ ์ถ๋ฐ์ผ
a_T: ํ๋ฆฐ ๋์ฐฉ์ผ, d_T: ํ๋ฆฐ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_V - a_V + 1 = 4
d_K - a_K + 1 = 3
d_R - a_R + 1 = 3
d_M - a_M + 1 = 5
d_T - a_T + 1 = 6
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_V, d_K, d_R, d_M, d_T) - min(a_V, a_K, a_R, a_M, a_T) + 1 = 17
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
a_K = 1
[10, 12] โฉ [a_R, d_R] โ โ
{3, 4} โฉ [a_M, d_M] โ โ
์งํญํธ์ด ์๋ ๋์:
(K โ R), (M โ K), (V โ K), (V โ M), (V โ T), (R โ V), (T โ R)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ํค์ด์ฐ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ํค์ด์ฐ์์ ๋ฏผ์คํฌ๋ก ๋นํ.
3-7์ผ์ฐจ: 5์ผ๊ฐ ๋ฏผ์คํฌ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ๋ฏผ์คํฌ์์ ๋น๋ด์ค๋ก ๋นํ.
7-10์ผ์ฐจ: 4์ผ๊ฐ ๋น๋ด์ค ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ๋น๋ด์ค์์ ๋ฆฌ๊ฐ๋ก ๋นํ.
10-12์ผ์ฐจ: 3์ผ๊ฐ ๋ฆฌ๊ฐ ๋ฐฉ๋ฌธ.
12์ผ์ฐจ: ๋ฆฌ๊ฐ์์ ํ๋ฆฐ์ผ๋ก ๋นํ.
12-17์ผ์ฐจ: 6์ผ๊ฐ ํ๋ฆฐ ๋ฐฉ๋ฌธ.
|
45
|
์ ๋ฝ
| 6
|
์ง์ ์์ฑ
|
์ด 18์ผ ๋์ ์ ๋ฝ 6๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ๋ฐ๋ธ๋ ์ผ๊ณผ ํจ๋ถ๋ฅดํฌ์ ๊ฐ๊ฐ 3์ผ๊ฐ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. ๋ฐ๋ธ๋ ์ผ์ ์ฒซ๋ฒ์งธ๋ก ๋ฐฉ๋ฌธํ๊ณ ์ถ์ต๋๋ค. ์ฌํ 17์ผ์ฐจ์ ํจ๋ถ๋ฅดํฌ์์ ์ถ๊ตฌ ๊ฒฝ๊ธฐ๋ฅผ ์ง๊ดํ ๊ฒ์
๋๋ค. ๋ธ๋คผ์
, ์ ๋ค๋ฐ, ์์ธ ๋ถ๋ฅดํฌ์ ๊ฐ๊ฐ 4์ผ๊ฐ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. ์ฌํ 4์ผ์ฐจ์ 6์ผ์ฐจ์ ์์ธ ๋ถ๋ฅดํฌ์์๋ ์ถ๊ตฌ ๊ฒฝ๊ธฐ ์ง๊ด์ ํ ๊ฒ์
๋๋ค. ๋ฆฌ์น์๋ 5์ผ๊ฐ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. 10์ผ๊ณผ 12์ผ ์ฌ์ด์ ๋ฆฌ์น์์ ์ด๋ชจ์ ๋ง๋๊ธฐ๋ก ํ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ์์ธ ๋ถ๋ฅดํฌ์ ๋ฆฌ์น, ์์ธ ๋ถ๋ฅดํฌ์ ๋ธ๋คผ์
, ์์ธ ๋ถ๋ฅดํฌ์ ๋ฐ๋ธ๋ ์ผ, ํจ๋ถ๋ฅดํฌ์ ๋ธ๋คผ์
, ํจ๋ธ๋ฃจํฌ์ ๋ฆฌ์น, ์ ๋ค๋ฐ์ ์์ธ ๋ถ๋ฅดํฌ, ๋ฆฌ์น๊ณผ ์ ๋ค๋ฐ, ๋ฆฌ์น๊ณผ ๋ธ๋คผ์
, ๋ฐ๋ธ๋ ์ผ๊ณผ ๋ธ๋คผ์
, ๋ฐ๋ธ๋ ์ผ๊ณผ ์์ธ ๋ถ๋ฅดํฌ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 18์ผ ๋์ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋ฐ๋ธ๋ ์ผ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋ฐ๋ธ๋ ์ผ์์ ์์ธ ๋ถ๋ฅดํฌ๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ์์ธ ๋ถ๋ฅดํฌ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์์ธ ๋ธ๋ฃจํฌ์์ ์ ๋ค๋ฐ๋ก ๋นํ.
6-9์ผ์ฐจ: 4์ผ๊ฐ ์ ๋ค๋ฐ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ์ ๋ค๋ฐ์์ ๋ฆฌ์น์ผ๋ก ๋นํ.
9-13์ผ์ฐจ: 5์ผ๊ฐ ๋ฆฌ์น ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ๋ฆฌ์น์์ ๋ธ๋คผ์
๋ก ๋นํ.
13-16์ผ์ฐจ: 4์ผ๊ฐ ๋ธ๋คผ์
๋ฐฉ๋ฌธ.
16์ผ์ฐจ: ๋ธ๋คผ์
์์ ํจ๋ถ๋ฅดํฌ๋ก ๋นํ.
16-18์ผ์ฐจ: 3์ผ๊ฐ ํจ๋ถ๋ฅดํฌ ๋ฐฉ๋ฌธ.
|
You plan to visit 6 cities in Europe for a total of 18 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'll visit Debresen and Hamburg for three days each. You would like to visit Debresen first. You will be in Hamburg on day 17 of your trip to watch a soccer match. You will be in Brussels, Geneva, and Salzburg for 4 days each. You will also watch a soccer game in Salzburg on days 4 and 6 of your trip. You will be in Lyon for 5 days. You will meet up with your aunt in Lyon between the 10th and 12th.
Here are the cities that have direct flights: Salzburg and Lyon, Salzburg and Brussels, Salzburg and Debresen, Hamburg and Brussels, Hamburg and Lyon, Geneva and Salzburg, Lyon and Geneva, Lyon and Brussels, Debresen and Brussels, Debresen and Salzburg.
Plan a trip to visit six cities in 18 days with direct flights.
|
Days 1-3: Visit Debresen for 3 days.
Day 3: Fly from Debresen to Salzburg.
Days 3-6: Visit Salzburg for 4 days.
Day 6: Fly from Salzburg to Geneva.
Days 6-9: Visit Geneva for 4 days.
Day 9: Fly from Geneva to Lyon.
Days 9-13: Visit Lyon for 5 days.
Day 13: Fly from Lyon to Brussels.
Days 13-16: Visit Brussels for 4 days.
Day 16: Fly from Brussels to Hamburg.
Days 16-18: Visit Hamburg for 3 days.
|
๋ณ์ ์ ์:
D: ๋ฐ๋ธ๋ ์ผ, H: ํจ๋ถ๋ฅดํฌ, B: ๋ธ๋คผ์
, G: ์ ๋ค๋ฐ, S: ์์ธ ๋ถ๋ฅดํฌ, L: ๋ฆฌ์น
a_D: ๋ฐ๋ธ๋ ์ผ ๋์ฐฉ์ผ, d_D: ๋ฐ๋ธ๋ ์ผ ์ถ๋ฐ์ผ
a_H: ํจ๋ถ๋ฅดํฌ ๋์ฐฉ์ผ, d_H: ํจ๋ถ๋ฅดํฌ ์ถ๋ฐ์ผ
a_B: ๋ธ๋คผ์
๋์ฐฉ์ผ, d_B: ๋ธ๋คผ์
์ถ๋ฐ์ผ
a_G: ์ ๋ค๋ฐ ๋์ฐฉ์ผ, d_G: ์ ๋ค๋ฐ ์ถ๋ฐ์ผ
a_S: ์์ธ ๋ถ๋ฅดํฌ ๋์ฐฉ์ผ, d_S: ์์ธ ๋ถ๋ฅดํฌ ์ถ๋ฐ์ผ
a_L: ๋ฆฌ์น ๋์ฐฉ์ผ, d_L: ๋ฆฌ์น ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_D - a_D + 1 = 3
d_H - a_H + 1 = 3
d_B - a_B + 1 = 4
d_G - a_G + 1 = 4
d_S - a_S + 1 = 4
d_L - a_L + 1 = 5
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_D, d_H, d_B, d_G, d_S, d_L) - min(a_D, a_H, a_B, a_G, a_S, a_L) + 1 = 18
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
a_D = 1
a_H โค 17 โค d_H
{4, 6} โ [a_S, d_S]
[10, 12] โฉ [a_L, d_L] โ โ
์งํญํธ์ด ์๋ ๋์:
(S โ L), (S โ B), (S โ D), (H โ B), (H โ L), (G โ S), (L โ G), (L โ B), (D โ B), (D โ S)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋ฐ๋ธ๋ ์ผ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋ฐ๋ธ๋ ์ผ์์ ์์ธ ๋ถ๋ฅดํฌ๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ์์ธ ๋ถ๋ฅดํฌ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์์ธ ๋ธ๋ฃจํฌ์์ ์ ๋ค๋ฐ๋ก ๋นํ.
6-9์ผ์ฐจ: 4์ผ๊ฐ ์ ๋ค๋ฐ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ์ ๋ค๋ฐ์์ ๋ฆฌ์น์ผ๋ก ๋นํ.
9-13์ผ์ฐจ: 5์ผ๊ฐ ๋ฆฌ์น ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ๋ฆฌ์น์์ ๋ธ๋คผ์
๋ก ๋นํ.
13-16์ผ์ฐจ: 4์ผ๊ฐ ๋ธ๋คผ์
๋ฐฉ๋ฌธ.
16์ผ์ฐจ: ๋ธ๋คผ์
์์ ํจ๋ถ๋ฅดํฌ๋ก ๋นํ.
16-18์ผ์ฐจ: 3์ผ๊ฐ ํจ๋ถ๋ฅดํฌ ๋ฐฉ๋ฌธ.
|
46
|
์ ๋ฝ
| 6
|
์ง์ ์์ฑ
|
์ด 19์ผ ๋์ ์ ๋ฝ 6๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ํฌ์ฑํค์์ 5์ผ๊ฐ ๋จธ๋ฌผ ์์ ์
๋๋ค. ์คํกํ๋กฌ์ 5์ผ ๋์ ๊ตฌ๊ฒฝํ๊ณ ์ถ์ต๋๋ค. ์คํกํ๋กฌ์ด ์ฌํ์ 5๋ฒ์งธ ์ฌํ์ง์์ผ๋ฉด ์ข๊ฒ ์ต๋๋ค. ์์คํ
๋ฅด๋ด์์ 2์ผ ๋์ ์์ ์์ ์
๋๋ค. 3์ผ ๋์์ ์ฝํํ๊ฒ์ ์์ ๊ฒ์
๋๋ค. 7์ผ๊ณผ 9์ผ ์ฌ์ด์ ์ฝํํ๊ฒ์ ์๋ ์น๊ตฌ์ ์ ํผ์ง์ ๋ฐฉ๋ฌธํ๋ ค๊ณ ํฉ๋๋ค. ๋ฒ ๋ฅผ๋ฆฐ์์ 6์ผ๊ฐ ๋จธ๋ฌผ ๊ฒ์
๋๋ค. ์ฌํ 2์ผ์ฐจ์ ๋ฒ ๋ฅผ๋ฆฐ์ ์ ๋ช
๋ ์คํ ๋์ ๊ฐ๋ ค๊ณ ํฉ๋๋ค. 3์ผ๊ฐ ์ค์ฌ๋ก๋ฅผ ๋ฐฉ๋ฌธํ ์์ ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ์์คํ
๋ฅด๋ด๊ณผ ๋ฒ ๋ฅผ๋ฆฐ, ์คํกํ๋กฌ๊ณผ ์ค์ฌ๋ก, ์คํกํ๋กฌ๊ณผ ์ฝํํ๊ฒ, ์ฝํํ๊ฒ๊ณผ ์์คํ
๋ฅด๋ด, ํฌ์ฑํค์ ์คํกํ๋กฌ, ์ค์ฌ๋ก์ ๋ฒ ๋ฅผ๋ฆฐ, ์ค์ฌ๋ก์ ์ฝํํ๊ฒ, ์ค์ฌ๋ก์ ์์คํ
๋ฅด๋ด.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 19์ผ ๋์ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-6์ผ์ฐจ: 6์ผ๊ฐ ๋ฒ ๋ฅผ๋ฆฐ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋ฒ ๋ฅผ๋ฆฐ์์ ์์คํ
๋ฅด๋ด๋ก ๋นํ.
6-7์ผ์ฐจ: 2์ผ๊ฐ ์์คํ
๋ฅด๋ด ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ์์คํ
๋ฅด๋ด์์ ์ฝํํ๊ฒ์ผ๋ก ๋นํ.
7-9์ผ์ฐจ: 3์ผ๊ฐ ์ฝํํ๊ฒ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ์ฝํํ๊ฒ์์ ์ค์ฌ๋ก๋ก ๋นํ.
9-11์ผ์ฐจ: 3์ผ๊ฐ ์ค์ฌ๋ก ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ์ค์ฌ๋ก์์ ์คํกํ๋กฌ์ผ๋ก ๋นํ.
11-15์ผ์ฐจ: 5์ผ๊ฐ ์คํกํ๋กฌ ๋ฐฉ๋ฌธ.
15์ผ์ฐจ: ์คํกํ๋กฌ์์ ํฌ์ฑํค๋ก ๋นํ.
15-19์ผ์ฐจ: 5์ผ๊ฐ ํฌ์ฑํค ๋ฐฉ๋ฌธ.
|
You plan to visit 6 cities in Europe for a total of 19 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You plan to spend 5 days in Helsinki. You want to spend 5 days exploring Stockholm. You'd like Stockholm to be the 5th stop on your trip. You'll be in Amsterdam for 2 days. You will be in Copenhagen for 3 days. You want to visit your friend's newlywed home in Copenhagen between the 7th and 9th. You'll be in Berlin for 6 days. You want to try a famous restaurant in Berlin on day 2 of your trip. You'll be visiting Oslo for 3 days.
Here are the cities that have direct flights: Amsterdam and Berlin, Stockholm and Oslo, Stockholm and Copenhagen, Copenhagen and Amsterdam, Helsinki and Stockholm, Oslo and Berlin, Oslo and Copenhagen, Oslo and Amsterdam.
Plan a trip to visit six cities in 19 days with direct flights.
|
Days 1-6: Visit Berlin for 6 days.
Day 6: Fly from Berlin to Amsterdam.
Days 6-7: Visit Amsterdam for 2 days.
Day 7: Fly from Amsterdam to Copenhagen.
Days 7-9: Visit Copenhagen for 3 days.
Day 9: Fly from Copenhagen to Oslo.
Days 9-11: Visit Oslo for 3 days.
Day 11: Fly from Oslo to Stockholm.
Days 11-15: Visit Stockholm for 5 days.
Day 15: Fly from Stockholm to Helsinki.
Days 15-19: Visit Helsinki for 5 days.
|
๋ณ์ ์ ์:
H: ํฌ์ฑํค, S: ์คํกํ๋กฌ, A: ์์คํ
๋ฅด๋ด, C: ์ฝํํ๊ฒ, B: ๋ฒ ๋ฅผ๋ฆฐ, O: ์ค์ฌ๋ก
a_H: ํฌ์ฑํค ๋์ฐฉ์ผ, d_H: ํฌ์ฑํค ์ถ๋ฐ์ผ
a_S: ์คํกํ๋กฌ ๋์ฐฉ์ผ, d_S: ์คํกํ๋กฌ ์ถ๋ฐ์ผ
a_A: ์์คํ
๋ฅด๋ด ๋์ฐฉ์ผ, d_A: ์์คํ
๋ฅด๋ด ์ถ๋ฐ์ผ
a_C: ์ฝํํ๊ฒ ๋์ฐฉ์ผ, d_C: ์ฝํํ๊ฒ ์ถ๋ฐ์ผ
a_B: ๋ฒ ๋ฅผ๋ฆฐ ๋์ฐฉ์ผ, d_B: ๋ฒ ๋ฅผ๋ฆฐ ์ถ๋ฐ์ผ
a_O: ์ค์ฌ๋ก ๋์ฐฉ์ผ, d_O: ์ค์ฌ๋ก ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_H - a_H + 1 = 5
d_S - a_S + 1 = 5
d_A - a_A + 1 = 2
d_C - a_C + 1 = 3
d_B - a_B + 1 = 6
d_O - a_O + 1 = 3
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_H, d_S, d_A, d_C, d_B, d_O) - min(a_H, a_S, a_A, a_C, a_B, a_O) + 1 = 19
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
a_S = min(a_H, a_A, a_C, a_B, a_O) + 4
[7, 9] โฉ [a_C, d_C] โ โ
a_B + 1 = 2
์งํญํธ์ด ์๋ ๋์:
(A โ B), (S โ O), (S โ C), (C โ A), (H โ S), (O โ B), (O โ C), (O โ A)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-6์ผ์ฐจ: 6์ผ๊ฐ ๋ฒ ๋ฅผ๋ฆฐ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋ฒ ๋ฅผ๋ฆฐ์์ ์์คํ
๋ฅด๋ด๋ก ๋นํ.
6-7์ผ์ฐจ: 2์ผ๊ฐ ์์คํ
๋ฅด๋ด ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ์์คํ
๋ฅด๋ด์์ ์ฝํํ๊ฒ์ผ๋ก ๋นํ.
7-9์ผ์ฐจ: 3์ผ๊ฐ ์ฝํํ๊ฒ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ์ฝํํ๊ฒ์์ ์ค์ฌ๋ก๋ก ๋นํ.
9-11์ผ์ฐจ: 3์ผ๊ฐ ์ค์ฌ๋ก ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ์ค์ฌ๋ก์์ ์คํกํ๋กฌ์ผ๋ก ๋นํ.
11-15์ผ์ฐจ: 5์ผ๊ฐ ์คํกํ๋กฌ ๋ฐฉ๋ฌธ.
15์ผ์ฐจ: ์คํกํ๋กฌ์์ ํฌ์ฑํค๋ก ๋นํ.
15-19์ผ์ฐจ: 5์ผ๊ฐ ํฌ์ฑํค ๋ฐฉ๋ฌธ.
|
47
|
์ ๋ฝ
| 6
|
์ง์ ์์ฑ
|
์ด 19์ผ ๋์ ์ ๋ฝ 6๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์ค๋ฅดํ์ค์์ 2์ผ๊ฐ ๋จธ๋ฌด๋ฅผ ์์ ์
๋๋ค. ๋ง๋ฅด์ธ์ ์์ 4์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. 5์ผ๊ฐ ์์คํ
๋ฅด๋ด์ ๋ฐฉ๋ฌธํ๋ ค๊ณ ํฉ๋๋ค. ๋ธ๋คผํค์์ 3์ผ์ ๋ณด๋ด๋ ค๊ณ ํฉ๋๋ค. ์ํ
๋ณด๋ฆฌ๋ฅผ 6์ผ๊ฐ ๋ฐฉ๋ฌธํ๊ณ ์ ํฉ๋๋ค. 17์ผ-18์ผ ์ฌ์ด์ ์ํ
๋ณด๋ฆฌ์์ ์ธ๋๋ฅผ ๋ง๋๊ธฐ๋ก ํ์ต๋๋ค. ๋ผ์ดํ์นํ์์ 4์ผ๊ฐ ์ฌํ์ ํ๋ ค๊ณ ํฉ๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ง๋ฅด์ธ์ ์ ๋ธ๋คผํค, ์ค๋ฅดํ์ค์ ๋ผ์ดํ์นํ, ๋ผ์ดํ์นํ์ ์์คํ
๋ฅด๋ด, ์ํ
๋ณด๋ฆฌ์ ์ค๋ฅดํ์ค, ์์คํ
๋ฅด๋ด๊ณผ ๋ธ๋คผํค.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 19์ผ ๋์ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ๋ง๋ฅด์ธ์ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ๋ง๋ฅด์ธ์ ์์ ๋ธ๋คผํค๋ก ๋นํ.
4-6์ผ์ฐจ: 3์ผ๊ฐ ๋ธ๋คผํค ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋ธ๋คผํค์์ ์์คํ
๋ฅด๋ด์ผ๋ก ๋นํ.
6-10์ผ์ฐจ: 5์ผ๊ฐ ์์คํ
๋ฅด๋ด ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ์์คํ
๋ฅด๋ด์์ ๋ผ์ดํ์นํ๋ก ๋นํ.
10-13์ผ์ฐจ: 4์ผ๊ฐ ๋ผ์ดํ์นํ ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ๋ผ์ดํ์นํ์์ ์ค๋ฅดํ์ค๋ก ๋นํ.
13-14์ผ์ฐจ: 2์ผ๊ฐ ์ค๋ฅดํ์ค ๋ฐฉ๋ฌธ.
14์ผ์ฐจ: ์ค๋ฅดํ์ค์์ ์ํ
๋ณด๋ฆฌ๋ก ๋นํ.
14-19์ผ์ฐจ: 6์ผ๊ฐ ์ํ
๋ณด๋ฆฌ ๋ฐฉ๋ฌธ.
|
You plan to visit 6 cities in Europe for a total of 19 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You plan to spend 2 days in Aarhus. You want to spend 4 days in Marseille. You want to visit Amsterdam for 5 days. You want to spend 3 days in Bruges. You want to visit Gothenburg for 6 days. You're meeting your sister in Gothenburg between the 17th and 18th. You want to spend 4 days in Leipzig.
Here are the cities that have direct flights: Marseille and Bruges, Aarhus and Leipzig, Leipzig and Amsterdam, Gothenburg and Aarhus, Amsterdam and Bruges.
Plan a trip to visit six cities in 19 days with direct flights.
|
Days 1-4: Visit Marseille for 4 days.
Day 4: Fly from Marseille to Bruges.
Days 4-6: Visit Bruges for 3 days.
Day 6: Fly from Bruges to Amsterdam.
Days 6-10: Visit Amsterdam for 5 days.
Day 10: Fly from Amsterdam to Leipzig.
Days 10-13: Visit Leipzig for 4 days.
Day 13: Fly from Leipzig to Aarhus.
Days 13-14: Visit Aarhus for 2 days.
Day 14: Fly from Aarhus to Gothenburg.
Days 14-19: Visit Gothenburg for 6 days.
|
๋ณ์ ์ ์:
A: ์ค๋ฅดํ์ค, M: ๋ง๋ฅด์ธ์ , Am: ์์คํ
๋ฅด๋ด, B: ๋ธ๋คผํค, G: ์ํ
๋ณด๋ฆฌ, L: ๋ผ์ดํ์นํ
a_A: ์ค๋ฅดํ์ค ๋์ฐฉ์ผ, d_A: ์ค๋ฅดํ์ค ์ถ๋ฐ์ผ
a_M: ๋ง๋ฅด์ธ์ ๋์ฐฉ์ผ, d_M: ๋ง๋ฅด์ธ์ ์ถ๋ฐ์ผ
a_Am: ์์คํ
๋ฅด๋ด ๋์ฐฉ์ผ, d_Am: ์์คํ
๋ฅด๋ด ์ถ๋ฐ์ผ
a_B: ๋ธ๋คผํค ๋์ฐฉ์ผ, d_B: ๋ธ๋คผํค ์ถ๋ฐ์ผ
a_G: ์ํ
๋ณด๋ฆฌ ๋์ฐฉ์ผ, d_G: ์ํ
๋ณด๋ฆฌ ์ถ๋ฐ์ผ
a_L: ๋ผ์ดํ์นํ ๋์ฐฉ์ผ, d_L: ๋ผ์ดํ์นํ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_A - a_A + 1 = 2
d_M - a_M + 1 = 4
d_Am - a_Am + 1 = 5
d_B - a_B + 1 = 3
d_G - a_G + 1 = 6
d_L - a_L + 1 = 4
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_A, d_M, d_Am, d_B, d_G, d_L) - min(a_A, a_M, a_Am, a_B, a_G, a_L) + 1 = 19
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[17, 18] โฉ [a_G, d_G] โ โ
์งํญํธ์ด ์๋ ๋์:
(M โ B), (A โ L), (L โ Am), (G โ A), (Am โ B)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ๋ง๋ฅด์ธ์ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ๋ง๋ฅด์ธ์ ์์ ๋ธ๋คผํค๋ก ๋นํ.
4-6์ผ์ฐจ: 3์ผ๊ฐ ๋ธ๋คผํค ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋ธ๋คผํค์์ ์์คํ
๋ฅด๋ด์ผ๋ก ๋นํ.
6-10์ผ์ฐจ: 5์ผ๊ฐ ์์คํ
๋ฅด๋ด ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ์์คํ
๋ฅด๋ด์์ ๋ผ์ดํ์นํ๋ก ๋นํ.
10-13์ผ์ฐจ: 4์ผ๊ฐ ๋ผ์ดํ์นํ ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ๋ผ์ดํ์นํ์์ ์ค๋ฅดํ์ค๋ก ๋นํ.
13-14์ผ์ฐจ: 2์ผ๊ฐ ์ค๋ฅดํ์ค ๋ฐฉ๋ฌธ.
14์ผ์ฐจ: ์ค๋ฅดํ์ค์์ ์ํ
๋ณด๋ฆฌ๋ก ๋นํ.
14-19์ผ์ฐจ: 6์ผ๊ฐ ์ํ
๋ณด๋ฆฌ ๋ฐฉ๋ฌธ.
|
48
|
์ ๋ฝ
| 6
|
์ง์ ์์ฑ
|
์ด 20์ผ ๋์ ์ ๋ฝ 6๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ๋๋ฅธ๋ฒ ๋ฅดํฌ์์ 5์ผ์ ๋ณด๋ผ ๊ฒ์
๋๋ค. ์ฌํ 2์ผ์ฐจ์ ๋๋ฅธ๋ฒ ๋ฅดํฌ์์ ์ฌ์ด์ ๋ง๋๊ธฐ๋ก ํ์ต๋๋ค. 4์ผ๊ฐ ํผ๋ ์ฒด๋ฅผ ์ฌํํ ๊ฒ์
๋๋ค. ์ธํฐ๋ผ์ผ์์ 4์ผ์ ๋ณด๋ด๊ณ ์ ํฉ๋๋ค. 6-8์ผ ์ฌ์ด์ ์ธํฐ๋ผ์ผ์ ์๋ ์ฐ์ ์ค๋ฅด๊ณ ์ ํฉ๋๋ค. ๋ฐ๋ฅด์ค๋ฐ์์ 5์ผ์ ๋ณด๋ผ ๊ฒ์
๋๋ค. ๊ทธ๋์ธ ์์ 3์ผ์ ๋จธ๋ฌผ๊ณ ์ ํฉ๋๋ค. ํ๋ผํ์์ 4์ผ์ ๋จธ๋ฌผ ์์ ์
๋๋ค. 13์ผ์์ 16์ผ ์ฌ์ด์๋ ํ๋ผํ์ ์๊ณ ์ถ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๊ทธ๋์ธ ์ ๋๋ฅธ๋ฒ ๋ฅดํฌ, ๊ทธ๋์ธ ์ ํผ๋ ์ฒด, ํ๋ผํ์ ๊ทธ๋์ธ , ๋ฐ๋ฅด์ค๋ฐ์ ํ๋ผํ, ๋ฐ๋ฅด์ค๋ฐ์ ์ธํฐ๋ผ์ผ, ์ธํฐ๋ผ์ผ๊ณผ ๋๋ฅธ๋ฒ ๋ฅดํฌ, ํผ๋ ์ฒด์ ๋๋ฅธ๋ฒ ๋ฅดํฌ, ํผ๋ ์ฒด์ ํ๋ผํ, ํผ๋ ์ฒด์ ์ธํฐ๋ผ์ผ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 20์ผ ๋์ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ๋๋ฅธ๋ฒ ๋ฅดํฌ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋๋ฅธ๋ฒ ๋ฅดํฌ์์ ์ธํฐ๋ผ์ผ์ผ๋ก ๋นํ.
5-8์ผ์ฐจ: 4์ผ๊ฐ ์ธํฐ๋ผ์ผ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ์ธํฐ๋ผ์ผ์์ ํผ๋ ์ฒด๋ก ๋นํ.
8-11์ผ์ฐจ: 4์ผ๊ฐ ํผ๋ ์ฒด ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ํผ๋ ์ฒด์์ ๊ทธ๋์ธ ๋ก ๋นํ.
11-13์ผ์ฐจ: 3์ผ๊ฐ ๊ทธ๋์ธ ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ๊ทธ๋์ธ ์์ ํ๋ผํ๋ก ๋นํ.
13-16์ผ์ฐจ: 4์ผ๊ฐ ํ๋ผํ ๋ฐฉ๋ฌธ.
16์ผ์ฐจ: ํ๋ผํ์์ ๋ฐ๋ฅด์ค๋ฐ๋ก ๋นํ.
16-20์ผ์ฐจ: 5์ผ๊ฐ ๋ฐ๋ฅด์ค๋ฐ ๋ฐฉ๋ฌธ.
|
You plan to visit 6 cities in Europe for a total of 20 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You will spend 5 days in Nuremberg. You plan to meet your cousin in Nuremberg on day 2 of your trip. You will travel to Florence for 4 days. You plan to spend 4 days in Interlaken. You plan to climb a mountain in Interlaken between days 6 and 8. You will spend 5 days in Warsaw. You want to spend 3 days in Graz. You plan to spend 4 days in Prague. You want to be in Prague between the 13th and 16th.
Here are the cities that have direct flights: Graz and Nuremberg, Graz and Florence, Prague and Graz, Warsaw and Prague, Warsaw and Interlaken, Interlaken and Nuremberg, Florence and Nuremberg, Florence and Prague, Florence and Interlaken.
Plan a trip to visit six cities in 20 days with direct flights.
|
Days 1-5: Visit Nuremberg for 5 days.
Day 5: Fly from Nuremberg to Interlaken.
Days 5-8: Visit Interlaken for 4 days.
Day 8: Fly from Interlaken to Florence.
Days 8-11: Visit Florence for 4 days.
Day 11: Fly from Florence to Graz.
Days 11-13: Visit Graz for 3 days.
Day 13: Fly from Graz to Prague.
Days 13-16: Visit Prague for 4 days.
Day 16: Fly from Prague to Warsaw.
Days 16-20: Visit Warsaw for 5 days.
|
๋ณ์ ์ ์:
N: ๋๋ฅธ๋ฒ ๋ฅดํฌ, F: ํผ๋ ์ฒด, I: ์ธํฐ๋ผ์ผ, W: ๋ฐ๋ฅด์ค๋ฐ, G: ๊ทธ๋์ธ , P: ํ๋ผํ
a_N: ๋๋ฅธ๋ฒ ๋ฅดํฌ ๋์ฐฉ์ผ, d_N: ๋๋ฅธ๋ฒ ๋ฅดํฌ ์ถ๋ฐ์ผ
a_F: ํผ๋ ์ฒด ๋์ฐฉ์ผ, d_F: ํผ๋ ์ฒด ์ถ๋ฐ์ผ
a_I: ์ธํฐ๋ผ์ผ ๋์ฐฉ์ผ, d_I: ์ธํฐ๋ผ์ผ ์ถ๋ฐ์ผ
a_W: ๋ฐ๋ฅด์ค๋ฐ ๋์ฐฉ์ผ, d_W: ๋ฐ๋ฅด์ค๋ฐ ์ถ๋ฐ์ผ
a_G: ๊ทธ๋์ธ ๋์ฐฉ์ผ, d_G: ๊ทธ๋์ธ ์ถ๋ฐ์ผ
a_P: ํ๋ผํ ๋์ฐฉ์ผ, d_P: ํ๋ผํ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_N - a_N + 1 = 5
d_F - a_F + 1 = 4
d_I - a_I + 1 = 4
d_W - a_W + 1 = 5
d_G - a_G + 1 = 3
d_P - a_P + 1 = 4
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_N, d_F, d_I, d_W, d_G, d_P) - min(a_N, a_F, a_I, a_W, a_G, a_P) + 1 = 20
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
a_N โค 2 โค d_N
[6, 8] โฉ [a_I, d_I] โ โ
[13, 16] โฉ [a_P, d_P] โ โ
์งํญํธ์ด ์๋ ๋์:
(G โ N), (G โ F), (P โ G), (W โ P), (W โ I), (I โ N), (F โ N), (F โ P), (F โ I)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ๋๋ฅธ๋ฒ ๋ฅดํฌ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋๋ฅธ๋ฒ ๋ฅดํฌ์์ ์ธํฐ๋ผ์ผ์ผ๋ก ๋นํ.
5-8์ผ์ฐจ: 4์ผ๊ฐ ์ธํฐ๋ผ์ผ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ์ธํฐ๋ผ์ผ์์ ํผ๋ ์ฒด๋ก ๋นํ.
8-11์ผ์ฐจ: 4์ผ๊ฐ ํผ๋ ์ฒด ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ํผ๋ ์ฒด์์ ๊ทธ๋์ธ ๋ก ๋นํ.
11-13์ผ์ฐจ: 3์ผ๊ฐ ๊ทธ๋์ธ ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ๊ทธ๋์ธ ์์ ํ๋ผํ๋ก ๋นํ.
13-16์ผ์ฐจ: 4์ผ๊ฐ ํ๋ผํ ๋ฐฉ๋ฌธ.
16์ผ์ฐจ: ํ๋ผํ์์ ๋ฐ๋ฅด์ค๋ฐ๋ก ๋นํ.
16-20์ผ์ฐจ: 5์ผ๊ฐ ๋ฐ๋ฅด์ค๋ฐ ๋ฐฉ๋ฌธ.
|
49
|
์ ๋ฝ
| 3
|
์ง์ ์์ฑ
|
์ด 10์ผ ๋์ ์ ๋ฝ 3๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ํค์๋์ฐ๋ฅผ 4์ผ ๋์ ๋ฐฉ๋ฌธํ๊ณ ์ถ์ต๋๋ค. ๋ฅด๋น๋ธ์์ 5์ผ ๋์ ๋จธ๋ฌผ๊ณ ์ถ์ต๋๋ค. 7์ผ์์ 9์ผ์ ์ฌ์ด์ ๋ฅด๋น๋ธ์์ ์น๊ตฌ๋ฅผ ๋ง๋๊ธฐ๋ก ํ์ต๋๋ค. 3์ผ ๋์ ๋ถ์ฟ ๋ ์ํฐ๋ฅผ ์ฌํํ๊ณ ์ถ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ถ์ฟ ๋ ์ํฐ์ ํค์๋์ฐ, ๋ฅด๋น๋ธ์ ํค์๋์ฐ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 10์ผ ๋์ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋ถ์ฟ ๋ ์ํฐ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋ถ์ฟ ๋ ์ํฐ์์ ํค์๋์ฐ๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ํค์๋์ฐ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ํค์๋์ฐ์์ ๋ฅด๋น๋ธ๋ก ๋นํ.
6-10์ผ์ฐจ: 5์ผ๊ฐ ๋ฅด๋น๋ธ ๋ฐฉ๋ฌธ.
|
You plan to visit 3 cities in Europe for a total of 10 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to visit Kishinev for 4 days. You want to stay in Lviv for 5 days. You want to meet a friend in Lviv between the 7th and 9th. You want to travel to Bucharest for 3 days.
Here are the cities that have direct flights: Bucharest and Khishinev, Lviv and Khishinev.
Plan a trip to visit the three cities in 10 days using direct flights.
|
Days 1-3: Visit Bucharest for 3 days.
Day 3: Fly from Bucharest to Kishinev.
Days 3-6: Visit Kishinev for 4 days.
Day 6: Fly from Kishinev to Lviv.
Days 6-10: Visit Lviv for 5 days.
|
๋ณ์ ์ ์:
K: ํค์๋์ฐ, L: ๋ฅด๋น๋ธ, B: ๋ถ์ฟ ๋ ์ํฐ
a_K: ํค์๋์ฐ ๋์ฐฉ์ผ, d_K: ํค์๋์ฐ ์ถ๋ฐ์ผ
a_L: ๋ฅด๋น๋ธ ๋์ฐฉ์ผ, d_L: ๋ฅด๋น๋ธ ์ถ๋ฐ์ผ
a_B: ๋ถ์ฟ ๋ ์ํฐ ๋์ฐฉ์ผ, d_B: ๋ถ์ฟ ๋ ์ํฐ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_K - a_K + 1 = 4
d_L - a_L + 1 = 5
d_B - a_B + 1 = 3
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_K, d_L, d_B) - min(a_K, a_L, a_B) + 1 = 10
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[7, 9] โฉ [a_L, d_L] โ โ
์งํญํธ์ด ์๋ ๋์:
(B โ K), (L โ K)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋ถ์ฟ ๋ ์ํฐ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋ถ์ฟ ๋ ์ํฐ์์ ํค์๋์ฐ๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ํค์๋์ฐ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ํค์๋์ฐ์์ ๋ฅด๋น๋ธ๋ก ๋นํ.
6-10์ผ์ฐจ: 5์ผ๊ฐ ๋ฅด๋น๋ธ ๋ฐฉ๋ฌธ.
|
50
|
์ ๋ฝ
| 3
|
์ง์ ์์ฑ
|
์ด 12์ผ ๋์ ์ ๋ฝ 3๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ๋ฒ ์ค๊ทธ๋ผ๋์์ 3์ผ ๋์ ์ฌํ์ ํ ์์ ์
๋๋ค. ๋นํธ์ฌ๋ผ์์ 5์ผ ๋์ ์ฒด๋ฅํ ์์ ์
๋๋ค. ์ํผ์์์ 6์ผ ๋์ ๋จธ๋ฌด๋ฅผ ์์ ์
๋๋ค. 2-3์ผ์ ์ํผ์์์ ์งํํ๋ ํฌ์ด์ ์ฐธ์ํ๊ณ ์ถ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ฒ ์ค๊ทธ๋ผ๋์ ์ํผ์, ๋ฒ ์ค๊ทธ๋ผ๋์ ๋นํธ์ฌ๋ผ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 12์ผ ๋์ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-6์ผ์ฐจ: 6์ผ๊ฐ ์ํผ์ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์ํผ์์์ ๋ฒ ์ค๊ทธ๋ผ๋๋ก ๋นํ.
6-8์ผ์ฐจ: 3์ผ๊ฐ ๋ฒ ์ค๊ทธ๋ผ๋ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ๋ฒ ์ค๊ทธ๋ผ๋์์ ๋นํธ์ฌ๋ผ๋ก ๋นํ.
8-12์ผ์ฐจ: 5์ผ๊ฐ ๋นํธ์ฌ๋ผ ๋ฐฉ๋ฌธ.
|
You plan to visit 3 cities in Europe for a total of 12 days.. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'll be traveling from Belgrade for 3 days. You'll be in Bitola for 5 days. You'll be in Sofia for 6 days. You want to attend a tour in Sofia on days 2-3.
Here are the cities that have direct flights: Belgrade and Sofia, Belgrade and Bitola.
Plan a trip to visit the three cities in 12 days using direct flights.
|
Days 1-6: Visit Sofia for 6 days.
Day 6: Fly from Sofia to Belgrade.
Days 6-8: Visit Belgrade for 3 days.
Day 8: Fly from Belgrade to Bitola.
Days 8-12: Visit Bitola for 5 days.
|
๋ณ์ ์ ์:
B: ๋ฒ ์ค๊ทธ๋ผ๋, M: ๋นํธ์ฌ๋ผ, S: ์ํผ์
a_B: ๋ฒ ์ค๊ทธ๋ผ๋ ๋์ฐฉ์ผ, d_B: ๋ฒ ์ค๊ทธ๋ผ๋ ์ถ๋ฐ์ผ
a_M: ๋นํธ์ฌ๋ผ ๋์ฐฉ์ผ, d_M: ๋นํธ์ฌ๋ผ ์ถ๋ฐ์ผ
a_S: ์ํผ์ ๋์ฐฉ์ผ, d_S: ์ํผ์ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_B - a_B + 1 = 3
d_M - a_M + 1 = 5
d_S - a_S + 1 = 6
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_B, d_M, d_S) - min(a_B, a_M, a_S) + 1 = 12
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
{2, 3} โ [a_S, d_S]
์งํญํธ์ด ์๋ ๋์:
(B โ S), (B โ M)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-6์ผ์ฐจ: 6์ผ๊ฐ ์ํผ์ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์ํผ์์์ ๋ฒ ์ค๊ทธ๋ผ๋๋ก ๋นํ.
6-8์ผ์ฐจ: 3์ผ๊ฐ ๋ฒ ์ค๊ทธ๋ผ๋ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ๋ฒ ์ค๊ทธ๋ผ๋์์ ๋นํธ์ฌ๋ผ๋ก ๋นํ.
8-12์ผ์ฐจ: 5์ผ๊ฐ ๋นํธ์ฌ๋ผ ๋ฐฉ๋ฌธ.
|
51
|
์ ๋ฝ
| 3
|
์ง์ ์์ฑ
|
์ด 14์ผ ๋์ ์ ๋ฝ 3๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. 4์ผ ๋์ ์ํผ์์ ๋จธ๋ฌผ ์์ ์
๋๋ค. ๋
ธ๋น์ฌ๋์ 5์ผ ๋์ ์ฒด๋ฅํ ๊ณํ์
๋๋ค. 10์ผ์์ 14์ผ ์ฌ์ด์ ๋
ธ๋น์ฌ๋์์ ์น๊ตฌ๋ฅผ ๋ง๋๊ณ ์ถ์ต๋๋ค. 7์ผ ๋์ ์์นด๋ผ๋ฅผ ๋ฐฉ๋ฌธํ๊ณ ์ถ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ์์นด๋ผ์ ์ํผ์, ๋
ธ๋น์ฌ๋์ ์ํผ์.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 14์ผ ๋์ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-7์ผ์ฐจ: 7์ผ๊ฐ ์์นด๋ผ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ์์นด๋ผ์์ ์ํผ์๋ก ๋นํ.
7-10์ผ์ฐจ: 4์ผ๊ฐ ์ํผ์ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ์ํผ์์์ ๋
ธ๋น์ฌ๋๋ก ๋นํ.
10-14์ผ์ฐจ: 5์ผ๊ฐ ๋
ธ๋น์ฌ๋ ๋ฐฉ๋ฌธ.
|
You plan to visit 3 cities in Europe for a total of 14 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You plan to stay in Sofia for 4 days. You plan to stay in Novi Sad for 5 days. You want to meet a friend in Novi Sad between days 10 and 14. You want to visit Ankara for 7 days.
Here are the cities that have direct flights: Ankara and Sofia, Novi Sad and Sofia.
Plan a trip to visit the three cities in 14 days using direct flights.
|
Days 1-7: Visit Ankara for 7 days.
Day 7: Fly from Ankara to Sofia.
Days 7-10: Visit Sofia for 4 days.
Day 10: Fly from Sofia to Novi Sad.
Days 10-14: Visit Novi Sad for 5 days.
|
๋ณ์ ์ ์:
S: ์ํผ์, N: ๋
ธ๋น์ฌ๋, A: ์์นด๋ผ
a_S: ์ํผ์ ๋์ฐฉ์ผ, d_S: ์ํผ์ ์ถ๋ฐ์ผ
a_N: ๋
ธ๋น์ฌ๋ ๋์ฐฉ์ผ, d_N: ๋
ธ๋น์ฌ๋ ์ถ๋ฐ์ผ
a_A: ์์นด๋ผ ๋์ฐฉ์ผ, d_A: ์์นด๋ผ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_S - a_S + 1 = 4
d_N - a_N + 1 = 5
d_A - a_A + 1 = 7
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_S, d_N, d_A) - min(a_S, a_N, a_A) + 1 = 14
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[10, 14] โฉ [a_N, d_N] โ โ
์งํญํธ์ด ์๋ ๋์:
(A โ S), (N โ S)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-7์ผ์ฐจ: 7์ผ๊ฐ ์์นด๋ผ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ์์นด๋ผ์์ ์ํผ์๋ก ๋นํ.
7-10์ผ์ฐจ: 4์ผ๊ฐ ์ํผ์ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ์ํผ์์์ ๋
ธ๋น์ฌ๋๋ก ๋นํ.
10-14์ผ์ฐจ: 5์ผ๊ฐ ๋
ธ๋น์ฌ๋ ๋ฐฉ๋ฌธ.
|
52
|
์ ๋ฝ
| 3
|
์ง์ ์์ฑ
|
์ด 8์ผ ๋์ ์ ๋ฝ 3๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ํผ๋ ์ฒด์์ 3์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. ํผ๋ ์ฒด์์ 2-3์ผ์ฐจ์ ์น๊ตฌ ์์ผํํฐ๋ฅผ ์ฐธ์ํ๊ธฐ๋ก ํ์ต๋๋ค. ๋ถ๋คํ์คํธ์์๋ 3์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. ๋ฅ๋ธ๋ด๋์์ 4์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ฅ๋ธ๋ด๋์ ํผ๋ ์ฒด, ๋ฅ๋ธ๋ด๋์ ๋ถ๋คํ์คํธ
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 8์ผ ๋์ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ํผ๋ ์ฒด ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ํผ๋ ์ฒด์์ ๋ฅ๋ธ๋ด๋๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ๋ฅ๋ธ๋ด๋ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋ฅ๋ธ๋ด๋์์ ๋ถ๋คํ์คํธ๋ก ๋นํ.
6-8์ผ์ฐจ: 3์ผ๊ฐ ๋ถ๋คํ์คํธ ๋ฐฉ๋ฌธ.
|
You plan to visit 3 cities in Europe for a total of 8 days.. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to spend 3 days in Florence. You plan to attend a friend's birthday party on days 2-3 in Florence. You also want to spend 3 days in Budapest. You want to spend 4 days in Ljubljana.
Here are the cities that have direct flights: Ljubljana and Florence, Ljubljana and Budapest.
Plan a trip to visit the three cities in 8 days using direct flights.
|
Days 1-3: Visit Florence for 3 days.
Day 3: Fly from Florence to Ljubljana.
Days 3-6: Visit Ljubljana for 4 days.
Day 6: Fly from Ljubljana to Budapest.
Days 6-8: Visit Budapest for 3 days.
|
๋ณ์ ์ ์:
F: ํผ๋ ์ฒด, B: ๋ถ๋คํ์คํธ, L: ๋ฅ๋ธ๋ด๋
a_F: ํผ๋ ์ฒด ๋์ฐฉ์ผ, d_F: ํผ๋ ์ฒด ์ถ๋ฐ์ผ
a_B: ๋ถ๋คํ์คํธ ๋์ฐฉ์ผ, d_B: ๋ถ๋คํ์คํธ ์ถ๋ฐ์ผ
a_L: ๋ฅ๋ธ๋ด๋ ๋์ฐฉ์ผ, d_L: ๋ฅ๋ธ๋ด๋ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_F - a_F + 1 = 3
d_B - a_B + 1 = 3
d_L - a_L + 1 = 4
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_F, d_B, d_L) - min(a_F, a_B, a_L) + 1 = 8
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
{2, 3} โ [a_F, d_F]
์งํญํธ์ด ์๋ ๋์:
(L โ F), (L โ B)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ํผ๋ ์ฒด ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ํผ๋ ์ฒด์์ ๋ฅ๋ธ๋ด๋๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ๋ฅ๋ธ๋ด๋ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋ฅ๋ธ๋ด๋์์ ๋ถ๋คํ์คํธ๋ก ๋นํ.
6-8์ผ์ฐจ: 3์ผ๊ฐ ๋ถ๋คํ์คํธ ๋ฐฉ๋ฌธ.
|
53
|
์ ๋ฝ
| 4
|
์ง์ ์์ฑ
|
์ด 14์ผ ๋์ ์ ๋ฝ 4๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. 6์ผ ๋์ ํจ๋ถ๋ฅดํฌ๋ฅผ ๋ฐฉ๋ฌธํ๊ณ ์ถ์ต๋๋ค. ํจ๋ถ๋ฅดํฌ๊ฐ ์ฌํ์ ๋ง์ง๋ง ์ฌ์ ์ง์์ผ๋ฉด ์ข๊ฒ ์ต๋๋ค. ์์คํ
๋ฅด๋ด์์ 4์ผ๊ฐ ๋จธ๋ฌด๋ฅผ ๊ณํ์
๋๋ค. ๋ฃฉ์
๋ถ๋ฅดํฌ์์ 3์ผ ๋์ ์ฌํ์ ์ฆ๊ธฐ๊ณ ์ถ์ต๋๋ค. ์ฌํ 8์ผ์งธ์ ๋ฃฉ์
๋ถ๋ฅดํฌ์์ ์ด๋ชจ๋ฅผ ๋ง๋๊ธฐ๋ก ํ์ต๋๋ค. ๊ฒํธ์์ 4์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๊ฒํธ์ ๋ฃฉ์
๋ถ๋ฅดํฌ, ํจ๋ถ๋ฅดํฌ์ ๋ฃฉ์
๋ถ๋ฅดํฌ, ์์คํ
๋ฅด๋ด๊ณผ ๋ฃฉ์
๋ถ๋ฅดํฌ, ์์คํ
๋ฅด๋ด๊ณผ ๊ฒํธ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 14์ผ ๋์ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ์์คํ
๋ฅด๋ด ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ์์คํ
๋ฅด๋ด์์ ๊ฒํธ๋ก ๋นํ.
4-7์ผ์ฐจ: 4์ผ๊ฐ ๊ฒํธ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ๊ฒํธ์์ ๋ฃฉ์
๋ถ๋ฅดํฌ๋ก ๋นํ.
7-9์ผ์ฐจ: 3์ผ๊ฐ ๋ฃฉ์
๋ถ๋ฅดํฌ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ๋ฃฉ์
๋ถ๋ฅดํฌ์์ ํจ๋ถ๋ฅดํฌ๋ก ๋นํ.
9-14์ผ์ฐจ: 6์ผ๊ฐ ํจ๋ถ๋ฅดํฌ ๋ฐฉ๋ฌธ.
|
You plan to visit 4 cities in Europe for a total of 14 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to visit Hamburg for 6 days. You want Hamburg to be the last stop on your trip. You plan to spend 4 days in Amsterdam. You want to spend 3 days in Luxembourg. You're meeting your aunt in Luxembourg on day 8 of your trip. You want to spend 4 days in Ghent.
Here are the cities that have direct flights: Ghent and Luxembourg, Hamburg and Luxembourg, Amsterdam and Luxembourg, Amsterdam and Ghent.
Plan a trip to visit four cities in 14 days using direct flights.
|
Days 1-4: Visit Amsterdam for 4 days.
Day 4: Fly from Amsterdam to Ghent.
Days 4-7: Visit Ghent for 4 days.
Day 7: Fly from Ghent to Luxembourg.
Days 7-9: Visit Luxembourg for 3 days.
Day 9: Fly from Luxembourg to Hamburg.
Days 9-14: Visit Hamburg for 6 days.
|
๋ณ์ ์ ์:
H: ํจ๋ถ๋ฅดํฌ, A: ์์คํ
๋ฅด๋ด, L: ๋ฃฉ์
๋ถ๋ฅดํฌ, G: ๊ฒํธ
a_H: ํจ๋ถ๋ฅดํฌ ๋์ฐฉ์ผ, d_H: ํจ๋ถ๋ฅดํฌ ์ถ๋ฐ์ผ
a_A: ์์คํ
๋ฅด๋ด ๋์ฐฉ์ผ, d_A: ์์คํ
๋ฅด๋ด ์ถ๋ฐ์ผ
a_L: ๋ฃฉ์
๋ถ๋ฅดํฌ ๋์ฐฉ์ผ, d_L: ๋ฃฉ์
๋ถ๋ฅดํฌ ์ถ๋ฐ์ผ
a_G: ๊ฒํธ ๋์ฐฉ์ผ, d_G: ๊ฒํธ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_H - a_H + 1 = 6
d_A - a_A + 1 = 4
d_L - a_L + 1 = 3
d_G - a_G + 1 = 4
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_H, d_A, d_L, d_G) - min(a_H, a_A, a_L, a_G) + 1 = 14
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
d_H = 14
8 โ [a_L, d_L]
์งํญํธ์ด ์๋ ๋์:
(G โ L), (H โ L), (A โ L), (A โ G)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ์์คํ
๋ฅด๋ด ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ์์คํ
๋ฅด๋ด์์ ๊ฒํธ๋ก ๋นํ.
4-7์ผ์ฐจ: 4์ผ๊ฐ ๊ฒํธ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ๊ฒํธ์์ ๋ฃฉ์
๋ถ๋ฅดํฌ๋ก ๋นํ.
7-9์ผ์ฐจ: 3์ผ๊ฐ ๋ฃฉ์
๋ถ๋ฅดํฌ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ๋ฃฉ์
๋ถ๋ฅดํฌ์์ ํจ๋ถ๋ฅดํฌ๋ก ๋นํ.
9-14์ผ์ฐจ: 6์ผ๊ฐ ํจ๋ถ๋ฅดํฌ ๋ฐฉ๋ฌธ.
|
54
|
์ ๋ฝ
| 4
|
์ง์ ์์ฑ
|
์ด 13์ผ ๋์ ์ ๋ฝ 4๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ํ๋ผํ์์ 5์ผ ๋์ ์ฌํ์ ํ ์์ ์
๋๋ค. 3์ผ ๋์ ๋ฎํจ์ ๋จธ๋ฌด๋ฅด๋ ค๊ณ ํฉ๋๋ค. ์์ธ ๋ถ๋ฅดํฌ์์๋ 3์ผ ๋์ ๋จธ๋ฌด๋ฅด๋ ค๊ณ ํฉ๋๋ค. ๋ฒ ๋ฅธ์ 5์ผ๊ฐ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. ์ฌํ 3์ผ์ฐจ์ ๋ฒ ๋ฅธ์์ ํํ์ ์ฐธ์ํ ์์ ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ํ๋ผํ์ ๋ฎํจ, ๋ฒ ๋ฅธ๊ณผ ๋ฎํจ, ํ๋ผํ์ ์์ธ ๋ถ๋ฅดํฌ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 13์ผ ๋์ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ๋ฒ ๋ฅธ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋ฒ ๋ฅธ์์ ๋ฎํจ์ผ๋ก ๋นํ.
5-7์ผ์ฐจ: 3์ผ๊ฐ ๋ฎํจ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ๋ฎํจ์์ ํ๋ผํ๋ก ๋นํ.
7-11์ผ์ฐจ: 5์ผ๊ฐ ํ๋ผํ ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ํ๋ผํ์์ ์์ธ ๋ถ๋ฅดํฌ๋ก ๋นํ.
11-13์ผ์ฐจ: 3์ผ๊ฐ ์์ธ ๋ถ๋ฅดํฌ ๋ฐฉ๋ฌธ.
|
You plan to visit 4 cities in Europe for a total of 13 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'll be traveling from Prague for 5 days. You'll be in Munich for 3 days. You'll also be in Salzburg for 3 days. You're traveling to Bern for 5 days. You'll be attending a conference in Bern on the 3 day of your trip.
Here are the cities that have direct flights: Prague and Munich, Bern and Munich, Prague and Salzburg.
Plan your trip to visit the four cities in 13 days using direct flights.
|
Days 1-5: Visit Bern for 5 days.
Day 5: Fly from Bern to Munich.
Days 5-7: Visit Munich for 3 days.
Day 7: Fly from Munich to Prague.
Days 7-11: Visit Prague for 5 days.
Day 11: Fly from Prague to Salzburg.
Days 11-13: Visit Salzburg for 3 days.
|
๋ณ์ ์ ์:
P: ํ๋ผํ, M: ๋ฎํจ, S: ์์ธ ๋ถ๋ฅดํฌ, B: ๋ฒ ๋ฅธ
a_P: ํ๋ผํ ๋์ฐฉ์ผ, d_P: ํ๋ผํ ์ถ๋ฐ์ผ
a_M: ๋ฎํจ ๋์ฐฉ์ผ, d_M: ๋ฎํจ ์ถ๋ฐ์ผ
a_S: ์์ธ ๋ถ๋ฅดํฌ ๋์ฐฉ์ผ, d_S: ์์ธ ๋ถ๋ฅดํฌ ์ถ๋ฐ์ผ
a_B: ๋ฒ ๋ฅธ ๋์ฐฉ์ผ, d_B: ๋ฒ ๋ฅธ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_P - a_P + 1 = 5
d_M - a_M + 1 = 3
d_S - a_S + 1 = 3
d_B - a_B + 1 = 5
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_P, d_M, d_S, d_B) - min(a_P, a_M, a_S, a_B) + 1 = 13
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
a_B โค 3 โค d_B
์งํญํธ์ด ์๋ ๋์:
(P โ M), (B โ M), (P โ S)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ๋ฒ ๋ฅธ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋ฒ ๋ฅธ์์ ๋ฎํจ์ผ๋ก ๋นํ.
5-7์ผ์ฐจ: 3์ผ๊ฐ ๋ฎํจ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ๋ฎํจ์์ ํ๋ผํ๋ก ๋นํ.
7-11์ผ์ฐจ: 5์ผ๊ฐ ํ๋ผํ ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ํ๋ผํ์์ ์์ธ ๋ถ๋ฅดํฌ๋ก ๋นํ.
11-13์ผ์ฐจ: 3์ผ๊ฐ ์์ธ ๋ถ๋ฅดํฌ ๋ฐฉ๋ฌธ.
|
55
|
์ ๋ฝ
| 4
|
์ง์ ์์ฑ
|
์ด 11์ผ ๋์ ์ ๋ฝ 4๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ํค์ํ, ํค์๋์ฐ, ๋ถ์ฟ ๋ ์ํฐ๋ฅผ ๊ฐ๊ฐ 3์ผ ๋์ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. ๋ถ์ฟ ๋ ์ํฐ๋ฅผ ๋์๋ค ์ค ๊ฐ์ฅ ๋ง์ง๋ง์ผ๋ก ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. 5์ผ ๋์ ๋ฐ๋ฅด์ค๋ฐ๋ฅผ ์ฌํํ ๊ฒ์
๋๋ค. ์ฌํ 2-3์ผ์ฐจ์ ๋ฐ๋ฅด์ค๋ฐ์์ ์ด๋ฆฌ๋ ์ผ์ด์ ๊ฒฐํผ์์ ์ฐธ์ํ ๊ฒ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ฐ๋ฅด์ค๋ฐ์ ํค์๋์ฐ, ํค์๋์ฐ์ ๋ถ์ฟ ๋ ์ํฐ, ํค์ํ์ ํค์๋์ฐ, ํค์ํ์ ๋ฐ๋ฅด์ค๋ฐ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 11์ผ ๋์ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ๋ฐ๋ฅด์ค๋ฐ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋ฐ๋ฅด์ค๋ฐ์์ ํค์ํ๋ก ๋นํ.
5-7์ผ์ฐจ: 3์ผ๊ฐ ํค์ํ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ํค์ํ์์ ํค์๋์ฐ๋ก ๋นํ.
7-9์ผ์ฐจ: 3์ผ๊ฐ ํค์๋์ฐ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ํค์๋์ฐ์์ ๋ถ์ฟ ๋ ์ํฐ๋ก ๋นํ.
9-11์ผ์ฐจ: 3์ผ๊ฐ ๋ถ์ฟ ๋ ์ํฐ ๋ฐฉ๋ฌธ.
|
You plan to visit 4 cities in Europe for a total of 11 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You will visit Kiev, Kishinev, and Bucharest for 3 days each. You will visit Bucharest last among the cities. You will travel to Warsaw for 5 days. You will attend your uncle's wedding in Warsaw on days 2-3 of your trip.
Here are the cities that have direct flights: Warsaw and Kishinev, Kishinev and Bucharest, Kiev and Kishinev, Kiev and Warsaw.
Plan your trip to visit four cities in 11 days with direct flights.
|
Days 1-5: Visit Warsaw for 5 days.
Day 5: Fly from Warsaw to Kiev.
Days 5-7: Visit Kiev for 3 days.
Day 7: Fly from Kiev to Kishinev.
Days 7-9: Visit Kishinev for 3 days.
Day 9: Fly from Kishinev to Bucharest.
Days 9-11: Visit Bucharest for 3 days.
|
๋ณ์ ์ ์:
K: ํค์ํ, C: ํค์๋์ฐ, B: ๋ถ์ฟ ๋ ์ํฐ, W: ๋ฐ๋ฅด์ค๋ฐ
a_K: ํค์ํ ๋์ฐฉ์ผ, d_K: ํค์ํ ์ถ๋ฐ์ผ
a_C: ํค์๋์ฐ ๋์ฐฉ์ผ, d_C: ํค์๋์ฐ ์ถ๋ฐ์ผ
a_B: ๋ถ์ฟ ๋ ์ํฐ ๋์ฐฉ์ผ, d_B: ๋ถ์ฟ ๋ ์ํฐ ์ถ๋ฐ์ผ
a_W: ๋ฐ๋ฅด์ค๋ฐ ๋์ฐฉ์ผ, d_W: ๋ฐ๋ฅด์ค๋ฐ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_K - a_K + 1 = 3
d_C - a_C + 1 = 3
d_B - a_B + 1 = 3
d_W - a_W + 1 = 5
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_K, d_C, d_B, d_W) - min(a_K, a_C, a_B, a_W) + 1 = 11
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
d_B = max(d_K, d_C, d_B, d_W)
{2, 3} โ [a_W, d_W]
์งํญํธ์ด ์๋ ๋์:
(W โ C), (C โ B), (K โ C), (K โ W)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ๋ฐ๋ฅด์ค๋ฐ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋ฐ๋ฅด์ค๋ฐ์์ ํค์ํ๋ก ๋นํ.
5-7์ผ์ฐจ: 3์ผ๊ฐ ํค์ํ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ํค์ํ์์ ํค์๋์ฐ๋ก ๋นํ.
7-9์ผ์ฐจ: 3์ผ๊ฐ ํค์๋์ฐ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ํค์๋์ฐ์์ ๋ถ์ฟ ๋ ์ํฐ๋ก ๋นํ.
9-11์ผ์ฐจ: 3์ผ๊ฐ ๋ถ์ฟ ๋ ์ํฐ ๋ฐฉ๋ฌธ.
|
56
|
์ ๋ฝ
| 4
|
์ง์ ์์ฑ
|
์ด 12์ผ ๋์ ์ ๋ฝ 4๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ํผ๋์์ 5์ผ์ ๋ณด๋ด๋ ค๊ณ ํฉ๋๋ค. 9์ผ๊ณผ 11์ผ ์ฌ์ด์ ํผ๋์์ ํฌ์ด๋ฅผ ์์ฝํด๋์์ต๋๋ค. 3์ผ๊ฐ ๋ถ๋๋ฐ๋ฅผ ๋ฐฉ๋ฌธํ๋ ค ํฉ๋๋ค. ์ฌํ 3-4์ผ์ฐจ์ ๋ถ๋๋ฐ์์ ์น๊ตฌ๋ฅผ ๋ง๋๊ธฐ๋ก ํ์ต๋๋ค. ํฐ๋ผ๋์์๋ 3์ผ๊ฐ ๋จธ๋ฌด๋ ค๊ณ ํฉ๋๋ค. ์๊ทธ๋ ๋ธ์์ 4์ผ์ ๋ณด๋ผ ๊ฒ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ์๊ทธ๋ ๋ธ์ ๋ถ๋๋ฐ, ์๊ทธ๋ ๋ธ์ ํฐ๋ผ๋, ํฐ๋ผ๋์ ๋ถ๋๋ฐ, ์๊ทธ๋ ๋ธ์ ํผ๋.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 12์ผ ๋์ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ํฐ๋ผ๋ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ํฐ๋ผ๋์์ ๋ถ๋๋ฐ๋ก ๋นํ.
3-5์ผ์ฐจ: 3์ผ๊ฐ ๋ถ๋๋ฐ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋ถ๋๋ฐ์์ ์๊ทธ๋ ๋ธ๋ก ๋นํ.
5-8์ผ์ฐจ: 4์ผ๊ฐ ์๊ทธ๋ ๋ธ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ์๊ทธ๋ ๋ธ์์ ํผ๋์ผ๋ก ๋นํ.
8-12์ผ์ฐจ: 5์ผ๊ฐ ํผ๋ ๋ฐฉ๋ฌธ.
|
You plan to visit 4 cities in Europe for a total of 12 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'll spend 5 days in Piran. You've booked a tour in Piran between the 9th and 11th. You'll visit Budva for 3 days. You'll meet a friend in Budva on days 3-4 of your trip. You also plan to spend 3 days in Tirana. You will spend 4 days in Zagreb.
Here are the cities that have direct flights: Zagreb and Budva, Zagreb and Tirana, Tirana and Budva, Zagreb and Piran.
Plan a trip to visit four cities in 12 days using direct flights.
|
Days 1-3: Visit Tirana for 3 days.
Day 3: Fly from Tirana to Budva.
Days 3-5: Visit Budva for 3 days.
Day 5: Fly from Budva to Zagreb.
Days 5-8: Visit Zagreb for 4 days.
Day 8: Fly from Zagreb to Piran.
Days 8-12: Visit Piran for 5 days.
|
๋ณ์ ์ ์:
P: ํผ๋, B: ๋ถ๋๋ฐ, T: ํฐ๋ผ๋, Z: ์๊ทธ๋ ๋ธ
a_P: ํผ๋ ๋์ฐฉ์ผ, d_P: ํผ๋ ์ถ๋ฐ์ผ
a_B: ๋ถ๋๋ฐ ๋์ฐฉ์ผ, d_B: ๋ถ๋๋ฐ ์ถ๋ฐ์ผ
a_T: ํฐ๋ผ๋ ๋์ฐฉ์ผ, d_T: ํฐ๋ผ๋ ์ถ๋ฐ์ผ
a_Z: ์๊ทธ๋ ๋ธ ๋์ฐฉ์ผ, d_Z: ์๊ทธ๋ ๋ธ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_P - a_P + 1 = 5
d_B - a_B + 1 = 3
d_T - a_T + 1 = 3
d_Z - a_Z + 1 = 4
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_P, d_B, d_T, d_Z) - min(a_P, a_B, a_T, a_Z) + 1 = 12
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[9, 11] โฉ [a_P, d_P] โ โ
{3, 4} โ [a_B, d_B]
์งํญํธ์ด ์๋ ๋์:
(Z โ B), (Z โ T), (T โ B), (Z โ P)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ํฐ๋ผ๋ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ํฐ๋ผ๋์์ ๋ถ๋๋ฐ๋ก ๋นํ.
3-5์ผ์ฐจ: 3์ผ๊ฐ ๋ถ๋๋ฐ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋ถ๋๋ฐ์์ ์๊ทธ๋ ๋ธ๋ก ๋นํ.
5-8์ผ์ฐจ: 4์ผ๊ฐ ์๊ทธ๋ ๋ธ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ์๊ทธ๋ ๋ธ์์ ํผ๋์ผ๋ก ๋นํ.
8-12์ผ์ฐจ: 5์ผ๊ฐ ํผ๋ ๋ฐฉ๋ฌธ.
|
57
|
์ ๋ฝ
| 5
|
์ง์ ์์ฑ
|
์ด 14์ผ ๋์ ์ ๋ฝ 5๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ๋ฐ๋ผ๋
ธ์์ 3์ผ์ ๋ณด๋ผ ๊ฒ์
๋๋ค. ๋์ค์์ 5์ผ๊ฐ ๋จธ๋ฌด๋ฅผ ๊ฒ์
๋๋ค. 3์ผ์ ๋์ค ํธ๋ ํฌ์ด๋ฅผ ๊ฐ๊ณ ์ถ์ต๋๋ค. 2์ผ ๋์ ์ ๋ค๋ฐ์ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. ๋ฆฌ์ค๋ณธ์์ 4์ผ์ ์ฌํํ๊ณ ์ ํฉ๋๋ค. 4์ผ๊ฐ ๋ฐ๋ฅด์
๋ก๋์ ์์ ์์ ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ฐ๋ฅด์
๋ก๋์ ๋ฐ๋ผ๋
ธ, ์ ๋ค๋ฐ์ ๋ฐ๋ผ๋
ธ, ๋์ค์ ์ ๋ค๋ฐ, ๋ฐ๋ฅด์
๋ก๋์ ๋ฆฌ์ค๋ณธ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 14์ผ ๋์ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ๋์ค ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋์ค์์ ์ ๋ค๋ฐ๋ก ๋นํ.
5-6์ผ์ฐจ: 2์ผ๊ฐ ์ ๋ค๋ฐ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์ ๋ค๋ฐ์์ ๋ฐ๋ผ๋
ธ๋ก ๋นํ.
6-8์ผ์ฐจ: 3์ผ๊ฐ ๋ฐ๋ผ๋
ธ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ๋ฐ๋ผ๋
ธ์์ ๋ฐ๋ฅด์
๋ก๋๋ก ๋นํ.
8-11์ผ์ฐจ: 4์ผ๊ฐ ๋ฐ๋ฅด์
๋ก๋ ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ๋ฐ๋ฅด์
๋ก๋์์ ๋ฆฌ์ค๋ณธ์ผ๋ก ๋นํ.
11-14์ผ์ฐจ: 4์ผ๊ฐ ๋ฆฌ์ค๋ณธ ๋ฐฉ๋ฌธ.
|
You plan to visit 5 cities in Europe for a total of 14 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You will spend 3 days in Milan. You will spend 5 days in Nice. You want to go on a Nice food tour on day 3. You will be in Geneva for 2 days. You want to spend 4 days in Lisbon. You will be in Barcelona for 4 days.
Here are the cities that have direct flights: Barcelona and Milan, Geneva and Milan, Nice and Geneva, Barcelona and Lisbon.
Plan a trip to visit five cities in 14 days using direct flights.
|
Days 1-5: Visit Nice for 5 days.
Day 5: Fly from Nice to Geneva.
Days 5-6: Visit Geneva for 2 days.
Day 6: Fly from Geneva to Milan.
Days 6-8: Visit Milan for 3 days.
Day 8: Fly from Milan to Barcelona.
Days 8-11: Visit Barcelona for 4 days.
Day 11: Fly from Barcelona to Lisbon.
Days 11-14: Visit Lisbon for 4 days.
|
๋ณ์ ์ ์:
M: ๋ฐ๋ผ๋
ธ, N: ๋์ค, G: ์ ๋ค๋ฐ, L: ๋ฆฌ์ค๋ณธ, B: ๋ฐ๋ฅด์
๋ก๋
a_M: ๋ฐ๋ผ๋
ธ ๋์ฐฉ์ผ, d_M: ๋ฐ๋ผ๋
ธ ์ถ๋ฐ์ผ
a_N: ๋์ค ๋์ฐฉ์ผ, d_N: ๋์ค ์ถ๋ฐ์ผ
a_G: ์ ๋ค๋ฐ ๋์ฐฉ์ผ, d_G: ์ ๋ค๋ฐ ์ถ๋ฐ์ผ
a_L: ๋ฆฌ์ค๋ณธ ๋์ฐฉ์ผ, d_L: ๋ฆฌ์ค๋ณธ ์ถ๋ฐ์ผ
a_B: ๋ฐ๋ฅด์
๋ก๋ ๋์ฐฉ์ผ, d_B: ๋ฐ๋ฅด์
๋ก๋ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_M - a_M + 1 = 3
d_N - a_N + 1 = 5
d_G - a_G + 1 = 2
d_L - a_L + 1 = 4
d_B - a_B + 1 = 4
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_M, d_N, d_G, d_L, d_B) - min(a_M, a_N, a_G, a_L, a_B) + 1 = 14
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
a_N โค 3 โค d_N
์งํญํธ์ด ์๋ ๋์:
(B โ M), (G โ M), (N โ G), (B โ L)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ๋์ค ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋์ค์์ ์ ๋ค๋ฐ๋ก ๋นํ.
5-6์ผ์ฐจ: 2์ผ๊ฐ ์ ๋ค๋ฐ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์ ๋ค๋ฐ์์ ๋ฐ๋ผ๋
ธ๋ก ๋นํ.
6-8์ผ์ฐจ: 3์ผ๊ฐ ๋ฐ๋ผ๋
ธ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ๋ฐ๋ผ๋
ธ์์ ๋ฐ๋ฅด์
๋ก๋๋ก ๋นํ.
8-11์ผ์ฐจ: 4์ผ๊ฐ ๋ฐ๋ฅด์
๋ก๋ ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ๋ฐ๋ฅด์
๋ก๋์์ ๋ฆฌ์ค๋ณธ์ผ๋ก ๋นํ.
11-14์ผ์ฐจ: 4์ผ๊ฐ ๋ฆฌ์ค๋ณธ ๋ฐฉ๋ฌธ.
|
58
|
์ ๋ฝ
| 5
|
์ง์ ์์ฑ
|
์ด 17์ผ ๋์ ์ ๋ฝ 5๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. 6์ผ ๋์ ์ํ
๋ค๋ฅผ ๋ฐฉ๋ฌธํ๋ ค๊ณ ํฉ๋๋ค. 15์ผ๊ณผ 16์ผ ์ฌ์ด์ ์ํ
๋ค ์ญ์ฌ ํฌ์ด๋ฅผ ์ ์ฒญํด๋์์ต๋๋ค. 3์ผ๊ฐ ๋ฆฌ๋ฒํ์ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. 4์ผ๊ฐ ์ธํฐ๋ผ์ผ์ ๋ฐฉ๋ฌธํ ์์ ์
๋๋ค. 5์ผ ๋์ ์์ ๋ฅด๋ง์์ ์๊ฐ์ ๋ณด๋ผ ๊ฒ์
๋๋ค. ์ฌํ 6์ผ์ฐจ์ ์
์ ๋ฅด๋งํ์ ์ถ๊ตฌ ๊ฒฝ๊ธฐ๋ฅผ ์ง๊ดํ ๊ฒ์
๋๋ค. 3์ผ ๋์ ๋ํด๋ฆฌ์์ ์๊ฐ์ ๋ณด๋ผ ๊ฒ์
๋๋ค. ์ฌํ 11์ผ์ฐจ์ ๋ํด๋ฆฌ์์ ์ ๋ช
ํ ํผ์์ง์ ์์ฝํด๋์์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ฆฌ๋ฒํ๊ณผ ์์ ๋ฅด๋ง, ์ธํฐ๋ผ์ผ๊ณผ ์ํ
๋ค, ์์ ๋ฅด๋ง๊ณผ ์ธํฐ๋ผ์ผ, ์ธํฐ๋ผ์ผ๊ณผ ๋ํด๋ฆฌ, ๋ํด๋ฆฌ์ ์ํ
๋ค, ๋ฆฌ๋ฒํ๊ณผ ๋ํด๋ฆฌ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 17์ผ ๋์ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋ฆฌ๋ฒํ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋ฆฌ๋ฒํ์์ ์์ ๋ฅด๋ง์ผ๋ก ๋นํ.
3-7์ผ์ฐจ: 5์ผ๊ฐ ์์ ๋ฅด๋ง ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ์์ ๋ฅด๋ง์์ ์ธํฐ๋ผ์ผ์ผ๋ก ๋นํ.
7-10์ผ์ฐจ: 4์ผ๊ฐ ์ธํฐ๋ผ์ผ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ์ธํฐ๋ผ์ผ์์ ๋ํด๋ฆฌ๋ก ๋นํ.
10-12์ผ์ฐจ: 3์ผ๊ฐ ๋ํด๋ฆฌ ๋ฐฉ๋ฌธ.
12์ผ์ฐจ: ๋ํด๋ฆฌ์์ ์ํ
๋ค๋ก ๋นํ.
12-17์ผ์ฐจ: 6์ผ๊ฐ ์ํ
๋ค ๋ฐฉ๋ฌธ.
|
You plan to visit 5 cities in Europe for a total of 17 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You plan to visit Athens for 6 days. Between the 15th and 16th, You've signed up for a historical tour of Athens. You'll be visiting Liverpool for 3 days. You'll be visiting Interlaken for 4 days. You'll spend 5 days in Saint-Germain. You'll watch a Saint-Germain soccer game on day 6 of your trip. You'll spend 3 days in Naples. You've made reservations for a famous pizzeria in Naples on day 11 of your trip.
Here are the cities that have direct flights: Liverpool and Saint-Germain, Interlaken and Athens, Saint-Germain and Interlaken, Interlaken and Naples, Naples and Athens, Liverpool and Naples.
Plan a trip to visit five cities in 17 days using direct flights.
|
Days 1-3: Visit Liverpool for 3 days.
Day 3: Fly from Liverpool to Saint-Germain.
Days 3-7: Visit Saint-Germain for 5 days.
Day 7: Fly from St. Germain to Interlaken.
Days 7-10: Visit Interlaken for 4 days.
Day 10: Fly from Interlaken to Naples.
Days 10-12: Visit Naples for 3 days.
Day 12: Fly from Naples to Athens.
Days 12-17: Visit Athens for 6 days.
|
๋ณ์ ์ ์:
A: ์ํ
๋ค, L: ๋ฆฌ๋ฒํ, I: ์ธํฐ๋ผ์ผ, S: ์์ ๋ฅด๋ง, N: ๋ํด๋ฆฌ
a_A: ์ํ
๋ค ๋์ฐฉ์ผ, d_A: ์ํ
๋ค ์ถ๋ฐ์ผ
a_L: ๋ฆฌ๋ฒํ ๋์ฐฉ์ผ, d_L: ๋ฆฌ๋ฒํ ์ถ๋ฐ์ผ
a_I: ์ธํฐ๋ผ์ผ ๋์ฐฉ์ผ, d_I: ์ธํฐ๋ผ์ผ ์ถ๋ฐ์ผ
a_S: ์์ ๋ฅด๋ง ๋์ฐฉ์ผ, d_S: ์์ ๋ฅด๋ง ์ถ๋ฐ์ผ
a_N: ๋ํด๋ฆฌ ๋์ฐฉ์ผ, d_N: ๋ํด๋ฆฌ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_A - a_A + 1 = 6
d_L - a_L + 1 = 3
d_I - a_I + 1 = 4
d_S - a_S + 1 = 5
d_N - a_N + 1 = 3
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_A, d_L, d_I, d_S, d_N) - min(a_A, a_L, a_I, a_S, a_N) + 1 = 17
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[15, 16] โฉ [a_A, d_A] โ โ
a_S โค 6 โค d_S
a_N โค 11 โค d_N
์งํญํธ์ด ์๋ ๋์:
(L โ S), (I โ A), (S โ I), (I โ N), (N โ A), (L โ N)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋ฆฌ๋ฒํ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋ฆฌ๋ฒํ์์ ์์ ๋ฅด๋ง์ผ๋ก ๋นํ.
3-7์ผ์ฐจ: 5์ผ๊ฐ ์์ ๋ฅด๋ง ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ์์ ๋ฅด๋ง์์ ์ธํฐ๋ผ์ผ์ผ๋ก ๋นํ.
7-10์ผ์ฐจ: 4์ผ๊ฐ ์ธํฐ๋ผ์ผ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ์ธํฐ๋ผ์ผ์์ ๋ํด๋ฆฌ๋ก ๋นํ.
10-12์ผ์ฐจ: 3์ผ๊ฐ ๋ํด๋ฆฌ ๋ฐฉ๋ฌธ.
12์ผ์ฐจ: ๋ํด๋ฆฌ์์ ์ํ
๋ค๋ก ๋นํ.
12-17์ผ์ฐจ: 6์ผ๊ฐ ์ํ
๋ค ๋ฐฉ๋ฌธ.
|
59
|
์ ๋ฝ
| 5
|
์ง์ ์์ฑ
|
์ด 15์ผ ๋์ ์ ๋ฝ 5๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ํ๋ผํ์์ 7์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. ์ฌํ 8์ผ์ฐจ์ ํ๋ผํ์์ ์ธ๋ ๊ฒฐํผ์์ ์ฐธ์ํ ์์ ์
๋๋ค. 4์ผ๊ฐ ๋ถ์ฟ ๋ ์ํฐ๋ฅผ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. 1-4์ผ์ ๋ถ์ฟ ๋ ์ํฐ์์ ์ง๋ผ ์์๋ฅผ ๋ฏธ๋ฆฌ ์์ฝํด๋์์ต๋๋ค. 3์ผ๊ฐ ๋ฅ๋ธ๋ด๋๋ฅผ ๋ฐฉ๋ฌธํ ์์ ์
๋๋ค. ๋ฐ๋ฅด์ค๋ฐ ๋ํ 3์ผ์ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. ๋น์์ 2์ผ์ ์ฌํํ ๊ฒ์
๋๋ค. 6์ผ๊ณผ 7์ผ ์ฌ์ด์๋ ๋น์ ๋ค๋ฌ์ผ ํฉ๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ํ๋ผํ์ ๋ฐ๋ฅด์ค๋ฐ, ๋น๊ณผ ๋ฐ๋ฅด์ค๋ฐ, ํ๋ผํ์ ๋ถ์ฟ ๋ ์ํฐ, ๋ฅ๋ธ๋ด๋์ ๋น, ๋ฅ๋ธ๋ด๋์ ๋ถ์ฟ ๋ ์ํฐ, ํ๋ผํ์ ๋น.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 15์ผ ๋์ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ๋ถ์ฟ ๋ ์ํฐ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ๋ถ๋ฃจ๋ ์ํฐ์์ ๋ฅ๋ธ๋ด๋๋ก ๋นํ.
4-6์ผ์ฐจ: 3์ผ๊ฐ ๋ฅ๋ธ๋ด๋ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋ฅ๋ธ๋ด๋์์ ๋น์ผ๋ก ๋นํ.
6-7์ผ์ฐจ: 2์ผ๊ฐ ๋น ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ๋น์์ ํ๋ผํ๋ก ๋นํ.
7-13์ผ์ฐจ: 7์ผ๊ฐ ํ๋ผํ ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ํ๋ผํ์์ ๋ฐ๋ฅด์ค๋ฐ๋ก ๋นํ.
13-15์ผ์ฐจ: 3์ผ๊ฐ ๋ฐ๋ฅด์ค๋ฐ ๋ฐฉ๋ฌธ.
|
You plan to visit 5 cities in Europe for a total of 15 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to spend 7 days in Prague. You will be attending your sister's wedding in Prague on day 8 of your trip. You'll visit Bucharest for 4 days. You've already booked a place to stay in Bucharest on days 1-4. You'll visit Ljubljana for 3 days. You'll also visit Warsaw for 3 days. You'll spend 2 days in Vienna. You need to stop by Vienna between the 6th and the 7th.
Here are the cities that have direct flights: Prague and Warsaw, Vienna and Warsaw, Prague and Bucharest, Ljubljana and Vienna, Ljubljana and Bucharest, Prague and Vienna.
Plan a trip to visit five cities in 15 days with direct flights.
|
Days 1-4: Visit Bucharest for 4 days.
Day 4: Fly from Bucharest to Ljubljana.
Days 4-6: Visit Ljubljana for 3 days.
Day 6: Fly from Ljubljana to Vienna.
Days 6-7: Visit Vienna for 2 days.
Day 7: Fly from Vienna to Prague.
Days 7-13: Visit Prague for 7 days.
Day 13: Fly from Prague to Warsaw.
Days 13-15: Visit Warsaw for 3 days.
|
๋ณ์ ์ ์:
P: ํ๋ผํ, B: ๋ถ์ฟ ๋ ์ํฐ, L: ๋ฅ๋ธ๋ด๋, W: ๋ฐ๋ฅด์ค๋ฐ, V: ๋น
a_P: ํ๋ผํ ๋์ฐฉ์ผ, d_P: ํ๋ผํ ์ถ๋ฐ์ผ
a_B: ๋ถ์ฟ ๋ ์ํฐ ๋์ฐฉ์ผ, d_B: ๋ถ์ฟ ๋ ์ํฐ ์ถ๋ฐ์ผ
a_L: ๋ฅ๋ธ๋ด๋ ๋์ฐฉ์ผ, d_L: ๋ฅ๋ธ๋ด๋ ์ถ๋ฐ์ผ
a_W: ๋ฐ๋ฅด์ค๋ฐ ๋์ฐฉ์ผ, d_W: ๋ฐ๋ฅด์ค๋ฐ ์ถ๋ฐ์ผ
a_V: ๋น ๋์ฐฉ์ผ, d_V: ๋น ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_P - a_P + 1 = 7
d_B - a_B + 1 = 4
d_L - a_L + 1 = 3
d_W - a_W + 1 = 3
d_V - a_V + 1 = 2
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_P, d_B, d_L, d_W, d_V) - min(a_P, a_B, a_L, a_W, a_V) + 1 = 15
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
a_P โค 8 โค d_P
a_B = 1, d_B = 4
[6, 7] โฉ [a_V, d_V] โ โ
์งํญํธ์ด ์๋ ๋์:
(P โ W), (V โ W), (P โ B), (L โ V), (L โ B), (P โ V)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ๋ถ์ฟ ๋ ์ํฐ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ๋ถ๋ฃจ๋ ์ํฐ์์ ๋ฅ๋ธ๋ด๋๋ก ๋นํ.
4-6์ผ์ฐจ: 3์ผ๊ฐ ๋ฅ๋ธ๋ด๋ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋ฅ๋ธ๋ด๋์์ ๋น์ผ๋ก ๋นํ.
6-7์ผ์ฐจ: 2์ผ๊ฐ ๋น ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ๋น์์ ํ๋ผํ๋ก ๋นํ.
7-13์ผ์ฐจ: 7์ผ๊ฐ ํ๋ผํ ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ํ๋ผํ์์ ๋ฐ๋ฅด์ค๋ฐ๋ก ๋นํ.
13-15์ผ์ฐจ: 3์ผ๊ฐ ๋ฐ๋ฅด์ค๋ฐ ๋ฐฉ๋ฌธ.
|
60
|
์ ๋ฝ
| 5
|
์ง์ ์์ฑ
|
์ด 18์ผ ๋์ ์ ๋ฝ 5๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์ํํฐ๋ํ์์ 7์ผ๊ฐ ์ฌํ์ ํ๊ณ ์ถ์ต๋๋ค. ๋ค ๋ฒ์งธ ์ฌํ์ง๋ ์ํํฐ๋ํ์์ผ๋ฉด ์ข๊ฒ ์ต๋๋ค. 5์ผ๊ฐ ๋ธ๋คผ์
์์ ์๊ฐ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. ๋ฒ ๋ฅผ๋ฆฐ์์ 3์ผ์ ๋ณด๋ด๋ ค๊ณ ํฉ๋๋ค. 3์ผ๊ฐ ์ฝํํ๊ฒ์์ ๋จธ๋ฌด๋ฅด๊ณ ์ถ์ต๋๋ค. 4์ผ๊ฐ ์์คํ
๋ฅด๋ด์ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ธ๋คผ์
๊ณผ ์ํํฐ๋ํ, ์์คํ
๋ฅด๋ด๊ณผ ์ฝํํ๊ฒ, ์์คํ
๋ฅด๋ด๊ณผ ๋ธ๋คผ์
, ๋ฒ ๋ฅผ๋ฆฐ๊ณผ ์ํํฐ๋ํ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 18์ผ ๋์ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ์ฝํํ๊ฒ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ์ฝํํ๊ฒ์์ ์์คํ
๋ฅด๋ด์ผ๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ์์คํ
๋ฅด๋ด ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์์คํ
๋ฅด๋ด์์ ๋ธ๋คผ์
๋ก ๋นํ.
6-10์ผ์ฐจ: 5์ผ๊ฐ ๋ธ๋คผ์
๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ๋ธ๋คผ์
์์ ์ํํฐ๋ํ๋ก ๋นํ.
10-16์ผ์ฐจ: 7์ผ๊ฐ ์ํํฐ๋ํ ๋ฐฉ๋ฌธ.
16์ผ์ฐจ: ์ํํฐ๋ํ์์ ๋ฒ ๋ฅผ๋ฆฐ์ผ๋ก ๋นํ.
16-18์ผ์ฐจ: 3์ผ๊ฐ ๋ฒ ๋ฅผ๋ฆฐ ๋ฐฉ๋ฌธ.
|
You plan to visit 5 cities in Europe for a total of 18 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to spend 7 days in Echternach. You would like Echternach to be your 4th destination. You want to spend 5 days in Brussels. You want to spend 3 days in Berlin. You want to spend 3 days in Copenhagen. You want to visit Amsterdam for 4 days.
Here are the cities that have direct flights: Brussels and Echternach, Amsterdam and Copenhagen, Amsterdam and Brussels, Berlin and Echternach.
Plan a trip to visit five cities in 18 days using direct flights.
|
Days 1-3: Visit Copenhagen for 3 days.
Day 3: Fly from Copenhagen to Amsterdam.
Days 3-6: Visit Amsterdam for 4 days.
Day 6: Fly from Amsterdam to Brussels.
Days 6-10: Visit Brussels for 5 days.
Day 10: Fly from Brussels to Echternach.
Days 10-16: Visit Echternach for 7 days.
Day 16: Fly from Echternach to Berlin.
Days 16-18: Visit Berlin for 3 days.
|
๋ณ์ ์ ์:
E: ์ํํฐ๋ํ, B: ๋ธ๋คผ์
, Be: ๋ฒ ๋ฅผ๋ฆฐ, C: ์ฝํํ๊ฒ, A: ์์คํ
๋ฅด๋ด
a_E: ์ํํฐ๋ํ ๋์ฐฉ์ผ, d_E: ์ํํฐ๋ํ ์ถ๋ฐ์ผ
a_B: ๋ธ๋คผ์
๋์ฐฉ์ผ, d_B: ๋ธ๋คผ์
์ถ๋ฐ์ผ
a_Be: ๋ฒ ๋ฅผ๋ฆฐ ๋์ฐฉ์ผ, d_Be: ๋ฒ ๋ฅผ๋ฆฐ ์ถ๋ฐ์ผ
a_C: ์ฝํํ๊ฒ ๋์ฐฉ์ผ, d_C: ์ฝํํ๊ฒ ์ถ๋ฐ์ผ
a_A: ์์คํ
๋ฅด๋ด ๋์ฐฉ์ผ, d_A: ์์คํ
๋ฅด๋ด ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_E - a_E + 1 = 7
d_B - a_B + 1 = 5
d_Be - a_Be + 1 = 3
d_C - a_C + 1 = 3
d_A - a_A + 1 = 4
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_E, d_B, d_Be, d_C, d_A) - min(a_E, a_B, a_Be, a_C, a_A) + 1 = 18
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
a_E > max(a_B, a_Be, a_C)
์งํญํธ์ด ์๋ ๋์:
(B โ E), (A โ C), (A โ B), (Be โ E)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ์ฝํํ๊ฒ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ์ฝํํ๊ฒ์์ ์์คํ
๋ฅด๋ด์ผ๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ์์คํ
๋ฅด๋ด ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์์คํ
๋ฅด๋ด์์ ๋ธ๋คผ์
๋ก ๋นํ.
6-10์ผ์ฐจ: 5์ผ๊ฐ ๋ธ๋คผ์
๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ๋ธ๋คผ์
์์ ์ํํฐ๋ํ๋ก ๋นํ.
10-16์ผ์ฐจ: 7์ผ๊ฐ ์ํํฐ๋ํ ๋ฐฉ๋ฌธ.
16์ผ์ฐจ: ์ํํฐ๋ํ์์ ๋ฒ ๋ฅผ๋ฆฐ์ผ๋ก ๋นํ.
16-18์ผ์ฐจ: 3์ผ๊ฐ ๋ฒ ๋ฅผ๋ฆฐ ๋ฐฉ๋ฌธ.
|
61
|
์ ๋ฝ
| 6
|
์ง์ ์์ฑ
|
์ด 17์ผ ๋์ ์ ๋ฝ 6๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ๋ฒ ๋์ค์์ 3์ผ์ ๋จธ๋ฌผ๊ณ ์ ํฉ๋๋ค. ๋ฒ ๋์ค์ ๋์ฐฉํ๋ 14์ผ ์น๊ตฌ๊ฐ ๊ณตํญ์ผ๋ก ํฝ์
์ ์จ๋ค๊ณ ํฉ๋๋ค. ๊ฒํธ๋ฅผ 5์ผ ๋์ ์ฌํํ ๊ฒ์
๋๋ค. ์์คํ
๋ฅด๋ด์ 4์ผ ๋์ ์์ ์์ ์
๋๋ค. 10์ผ๋ถํฐ 12์ผ ์ฌ์ด์ ์์คํ
๋ฅด๋ด์์ ์ด๋ฆฌ๋ ์ ์ํ๋ฅผ ๋ณด๋ฌ๊ฐ ์์ ์
๋๋ค. 5์ผ๊ฐ ๋ฐ๋์ ์์ ์์ ์
๋๋ค. 2-4์ผ ์ฌ์ด์ ๋ฐ๋์ ์๋ ์น์ฒ์ง์ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. ํจ๋ถ๋ฅดํฌ์์๋ 3์ผ์ ๋ณด๋ด๋ ค๊ณ ํฉ๋๋ค. ์ทจ๋ฆฌํ์์๋ 2์ผ์ ๋ณด๋ผ ๊ฒ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๊ฒํธ์ ์์คํ
๋ฅด๋ด, ๋ฒ ๋์ค์ ๋ฐ๋, ๋ฒ ๋์ค์ ์ทจ๋ฆฌํ, ํจ๋ถ๋ฅดํฌ์ ๋ฒ ๋์ค, ์์คํ
๋ฅด๋ด๊ณผ ์ทจ๋ฆฌํ, ์์คํ
๋ฅด๋ด๊ณผ ๋ฒ ๋์ค, ํจ๋ถ๋ฅดํฌ์ ์์คํ
๋ฅด๋ด, ๋ฐ๋๊ณผ ๊ฒํธ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 17์ผ ๋์ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ๋ฐ๋ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋ฐ๋์์ ๊ฒํธ๋ก ๋นํ.
5-9์ผ์ฐจ: 5์ผ๊ฐ ๊ฒํธ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ๊ฒํธ์์ ์์คํ
๋ฅด๋ด์ผ๋ก ๋นํ.
9-12์ผ์ฐจ: 4์ผ๊ฐ ์์คํ
๋ฅด๋ด ๋ฐฉ๋ฌธ.
12์ผ์ฐจ: ์์คํ
๋ฅด๋ด์์ ํจ๋ถ๋ฅดํฌ๋ก ๋นํ.
12-14์ผ์ฐจ: 3์ผ๊ฐ ํจ๋ถ๋ฅดํฌ ๋ฐฉ๋ฌธ.
14์ผ์ฐจ: ํจ๋ถ๋ฅดํฌ์์ ๋ฒ ๋์ค๋ก ๋นํ.
14-16์ผ์ฐจ: 3์ผ๊ฐ ๋ฒ ๋์ค ๋ฐฉ๋ฌธ.
16์ผ์ฐจ: ๋ฒ ๋์ค์์ ์ทจ๋ฆฌํ๋ก ๋นํ.
16-17์ผ์ฐจ: 2์ผ๊ฐ ์ทจ๋ฆฌํ ๋ฐฉ๋ฌธ.
|
You plan to visit 6 cities in Europe for a total of 17 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You plan to spend 3 days in Venice. A friend is picking you up at the airport on the 14th when you arrive in Venice. You will be traveling to Ghent for 5 days. You will be in Amsterdam for 4 days. You are going to an exhibition in Amsterdam between the 10th and 12th. You will be in London for 5 days. Between days 2 and 4, you will visit a relative in London. You're going to spend 3 days in Hamburg. You will spend 2 days in Zurich.
Here are the cities that have direct flights: Ghent and Amsterdam, Venice and London, Venice and Zurich, Hamburg and Venice, Amsterdam and Zurich, Amsterdam and Venice, Hamburg and Amsterdam, London and Ghent.
Plan a trip to visit six cities in 17 days with direct flights.
|
Days 1-5: Visit London for 5 days.
Day 5: Fly from London to Ghent.
Days 5-9: Visit Ghent for 5 days.
Day 9: Fly from Ghent to Amsterdam.
Days 9-12: Visit Amsterdam for 4 days.
Day 12: Fly from Amsterdam to Hamburg.
Days 12-14: Visit Hamburg for 3 days.
Day 14: Fly from Hamburg to Venice.
Days 14-16: Visit Venice for 3 days.
Day 16: Fly from Venice to Zurich.
Days 16-17: Visit Zurich for 2 days.
|
๋ณ์ ์ ์:
V: ๋ฒ ๋์ค, G: ๊ฒํธ, A: ์์คํ
๋ฅด๋ด, L: ๋ฐ๋, H: ํจ๋ถ๋ฅดํฌ, Z: ์ทจ๋ฆฌํ
a_V: ๋ฒ ๋์ค ๋์ฐฉ์ผ, d_V: ๋ฒ ๋์ค ์ถ๋ฐ์ผ
a_G: ๊ฒํธ ๋์ฐฉ์ผ, d_G: ๊ฒํธ ์ถ๋ฐ์ผ
a_A: ์์คํ
๋ฅด๋ด ๋์ฐฉ์ผ, d_A: ์์คํ
๋ฅด๋ด ์ถ๋ฐ์ผ
a_L: ๋ฐ๋ ๋์ฐฉ์ผ, d_L: ๋ฐ๋ ์ถ๋ฐ์ผ
a_H: ํจ๋ถ๋ฅดํฌ ๋์ฐฉ์ผ, d_H: ํจ๋ถ๋ฅดํฌ ์ถ๋ฐ์ผ
a_Z: ์ทจ๋ฆฌํ ๋์ฐฉ์ผ, d_Z: ์ทจ๋ฆฌํ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_V - a_V + 1 = 3
d_G - a_G + 1 = 5
d_A - a_A + 1 = 4
d_L - a_L + 1 = 5
d_H - a_H + 1 = 3
d_Z - a_Z + 1 = 2
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_V, d_G, d_A, d_L, d_H, d_Z) - min(a_V, a_G, a_A, a_L, a_H, a_Z) + 1 = 17
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
a_V = 14
[10, 12] โฉ [a_A, d_A] โ โ
[2, 4] โฉ [a_L, d_L] โ โ
์งํญํธ์ด ์๋ ๋์:
(G โ A), (V โ L), (V โ Z), (H โ V), (A โ Z), (A โ V), (H โ A), (L โ G)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ๋ฐ๋ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋ฐ๋์์ ๊ฒํธ๋ก ๋นํ.
5-9์ผ์ฐจ: 5์ผ๊ฐ ๊ฒํธ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ๊ฒํธ์์ ์์คํ
๋ฅด๋ด์ผ๋ก ๋นํ.
9-12์ผ์ฐจ: 4์ผ๊ฐ ์์คํ
๋ฅด๋ด ๋ฐฉ๋ฌธ.
12์ผ์ฐจ: ์์คํ
๋ฅด๋ด์์ ํจ๋ถ๋ฅดํฌ๋ก ๋นํ.
12-14์ผ์ฐจ: 3์ผ๊ฐ ํจ๋ถ๋ฅดํฌ ๋ฐฉ๋ฌธ.
14์ผ์ฐจ: ํจ๋ถ๋ฅดํฌ์์ ๋ฒ ๋์ค๋ก ๋นํ.
14-16์ผ์ฐจ: 3์ผ๊ฐ ๋ฒ ๋์ค ๋ฐฉ๋ฌธ.
16์ผ์ฐจ: ๋ฒ ๋์ค์์ ์ทจ๋ฆฌํ๋ก ๋นํ.
16-17์ผ์ฐจ: 2์ผ๊ฐ ์ทจ๋ฆฌํ ๋ฐฉ๋ฌธ.
|
62
|
์ ๋ฝ
| 6
|
์ง์ ์์ฑ
|
์ด 20์ผ ๋์ ์ ๋ฝ 6๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. 3์ผ ๋์ ์๊ทธ๋ ๋ธ์์ ์ฌํ์ ํ๊ณ ์ถ์ต๋๋ค. ํ๋ํฌํธ๋ฅดํธ์ ํ์ ์์ ๊ฐ๊ฐ 4์ผ์ ๋ณด๋ด๊ณ ์ ํฉ๋๋ค. ํ๋ํฌํธ๋ฅดํธ์์ 2์ผ๊ณผ 3์ผ ์ฌ์ด์ ์ฌ์
ํํธ๋๋ฅผ ๋ง๋๊ธฐ๋ก ํ์ต๋๋ค. ํ ์ํํธ์์ 2์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. ํ ์ํํธ๊ฐ ๋ง์ง๋ง ์ฌ์ ์ง์์ผ๋ฉด ์ข๊ฒ ์ต๋๋ค. 7์ผ๊ฐ์ ํ์น์ ์์ผ๋ ค๊ณ ํฉ๋๋ค. 10์ผ๋ถํฐ 13์ผ ์ฌ์ด์ ํ์น์์ ํฌ์ด์ ์ฐธ์ฌํ ๊ฒ์
๋๋ค. 5์ผ๊ฐ ๋ฅ๋ธ๋ด๋๋ฅผ ๋ฐฉ๋ฌธํ ์์ ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ํ๋ํฌํธ๋ฅดํธ์ ํ์ , ํ์ ๊ณผ ํ์น, ํ๋ํฌํธ๋ฅดํธ์ ํ ์ํํธ, ์๊ทธ๋ ๋ธ์ ํ์น, ํ๋ํฌํธ๋ฅดํธ์ ํ์น, ๋ฅ๋ธ๋ด๋์ ์๊ทธ๋ ๋ธ, ํ ์ํํธ์ ํ์น, ๋ฅ๋ธ๋ด๋์ ํ ์ํํธ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 20์ผ ๋์ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ํ๋ํฌํธ๋ฅดํธ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ํ๋ํฌํธ๋ฅดํธ์์ ํ์ ์ผ๋ก ๋นํ.
4-7์ผ์ฐจ: 4์ผ๊ฐ ํ์ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ํ์ ์์ ํ์น๋ก ๋นํ.
7-13์ผ์ฐจ: 7์ผ๊ฐ ํ์น ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ํ์น์์ ์๊ทธ๋ ๋ธ๋ก ๋นํ.
13-15์ผ์ฐจ: 3์ผ๊ฐ ์๊ทธ๋ ๋ธ ๋ฐฉ๋ฌธ.
15์ผ์ฐจ: ์๊ทธ๋ ๋ธ์์ ๋ฅ๋ธ๋ด๋๋ก ๋นํ.
15-19์ผ์ฐจ: 5์ผ๊ฐ ๋ฅ๋ธ๋ด๋ ๋ฐฉ๋ฌธ.
19์ผ์ฐจ: ๋ฅ๋ธ๋ด๋์์ ํ ์ํํธ๋ก ๋นํ.
19-20์ผ์ฐจ: 2์ผ๊ฐ ํ ์ํํธ ๋ฐฉ๋ฌธ.
|
You plan to visit 6 cities in Europe for a total of 20 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to spend 3 days in Zagreb. You want to spend 4 days each in Frankfurt and Plzen. You want to meet with a business partner in Frankfurt on days 2 and 3. You want to spend 2 days in Hallstatt. You want Hallstatt to be the last stop on your itinerary. You want to be in Pecs for 7 days. Between the 10th and 13th, you will join a tour in Pecs. You will visit Ljubljana for 5 days.
Here are the cities that have direct flights: Frankfurt and Plzen, Plzen and Pecs, Frankfurt and Hallstatt, Zagreb and Pecs, Frankfurt and Pecs, Ljubljana and Zagreb, Hallstatt and Pecs, Ljubljana and Hallstatt.
Plan a trip to visit six cities in 20 days with direct flights.
|
Days 1-4: Visit Frankfurt for 4 days.
Day 4: Fly from Frankfurt to Plzen.
Days 4-7: Visit Plzen for 4 days.
Day 7: Fly from Plzen to Pecs.
Days 7-13: Visit Pecs for 7 days.
Day 13: Fly from Pecs to Zagreb.
Days 13-15: Visit Zagreb for 3 days.
Day 15: Fly from Zagreb to Ljubljana.
Days 15-19: Visit Ljubljana for 5 days.
Day 19: Fly from Ljubljana to Hallstatt.
Days 19-20: Visit Hallstatt for 2 days.
|
๋ณ์ ์ ์:
Z: ์๊ทธ๋ ๋ธ, F: ํ๋ํฌํธ๋ฅดํธ, P: ํ์ , H: ํ ์ํํธ, Pe: ํ์น, L: ๋ฅ๋ธ๋ด๋
a_Z: ์๊ทธ๋ ๋ธ ๋์ฐฉ์ผ, d_Z: ์๊ทธ๋ ๋ธ ์ถ๋ฐ์ผ
a_F: ํ๋ํฌํธ๋ฅดํธ ๋์ฐฉ์ผ, d_F: ํ๋ํฌํธ๋ฅดํธ ์ถ๋ฐ์ผ
a_P: ํ์ ๋์ฐฉ์ผ, d_P: ํ์ ์ถ๋ฐ์ผ
a_H: ํ ์ํํธ ๋์ฐฉ์ผ, d_H: ํ ์ํํธ ์ถ๋ฐ์ผ
a_Pe: ํ์น ๋์ฐฉ์ผ, d_Pe: ํ์น ์ถ๋ฐ์ผ
a_L: ๋ฅ๋ธ๋ด๋ ๋์ฐฉ์ผ, d_L: ๋ฅ๋ธ๋ด๋ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_Z - a_Z + 1 = 3
d_F - a_F + 1 = 4
d_P - a_P + 1 = 4
d_H - a_H + 1 = 2
d_Pe - a_Pe + 1 = 7
d_L - a_L + 1 = 5
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_Z, d_F, d_P, d_H, d_Pe, d_L) - min(a_Z, a_F, a_P, a_H, a_Pe, a_L) + 1 = 20
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
{2, 3} โ [a_F, d_F]
[10, 13] โฉ [a_Pe, d_Pe] โ โ
d_H = max(d_Z, d_F, d_P, d_H, d_Pe, d_L)
์งํญํธ์ด ์๋ ๋์:
(F โ P), (P โ Pe), (F โ H), (Z โ Pe), (F โ Pe), (L โ Z), (H โ Pe), (L โ H)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ํ๋ํฌํธ๋ฅดํธ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ํ๋ํฌํธ๋ฅดํธ์์ ํ์ ์ผ๋ก ๋นํ.
4-7์ผ์ฐจ: 4์ผ๊ฐ ํ์ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ํ์ ์์ ํ์น๋ก ๋นํ.
7-13์ผ์ฐจ: 7์ผ๊ฐ ํ์น ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ํ์น์์ ์๊ทธ๋ ๋ธ๋ก ๋นํ.
13-15์ผ์ฐจ: 3์ผ๊ฐ ์๊ทธ๋ ๋ธ ๋ฐฉ๋ฌธ.
15์ผ์ฐจ: ์๊ทธ๋ ๋ธ์์ ๋ฅ๋ธ๋ด๋๋ก ๋นํ.
15-19์ผ์ฐจ: 5์ผ๊ฐ ๋ฅ๋ธ๋ด๋ ๋ฐฉ๋ฌธ.
19์ผ์ฐจ: ๋ฅ๋ธ๋ด๋์์ ํ ์ํํธ๋ก ๋นํ.
19-20์ผ์ฐจ: 2์ผ๊ฐ ํ ์ํํธ ๋ฐฉ๋ฌธ.
|
63
|
์ ๋ฝ
| 6
|
์ง์ ์์ฑ
|
์ด 21์ผ ๋์ ์ ๋ฝ 6๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์พฐ๋ฅธ์์ 4์ผ๊ฐ ๋จธ๋ฌผ ๊ฒ์
๋๋ค. 6์ผ๊ฐ ์๊ทธ๋ ๋ธ๋ฅผ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. 5์ผ ๋์ ๋น์์ ๋จธ๋ฌผ ๊ฒ์
๋๋ค.
ํ๋ผํ๋ฅผ 5์ผ ๋์ ์ฌํํ ์์ ์
๋๋ค. 18-20์ผ ์ฌ์ด์๋ ๋ฌด์กฐ๊ฑด ํ๋ผํ์ ์์ด์ผ ํฉ๋๋ค. 3์ผ๊ฐ ๋ฅ๋ธ๋ด๋๋ฅผ ์ฌํํ๋ ค๊ณ ํฉ๋๋ค. ๋ถ๋คํ์คํธ์์ 3์ผ๊ฐ ์์ ๊ฒ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋น๊ณผ ์พฐ๋ฅธ, ๋ฅ๋ธ๋ด๋์ ๋น, ํ๋ผํ์ ๋ถ๋คํ์คํธ, ์๊ทธ๋ ๋ธ์ ๋ถ๋คํ์คํธ, ๋ฅ๋ธ๋ด๋์ ์๊ทธ๋ ๋ธ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 21์ผ ๋์ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ์พฐ๋ฅธ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ์พฐ๋ฅธ์์ ๋น์ผ๋ก ๋นํ.
4-8์ผ์ฐจ: 5์ผ๊ฐ ๋น ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ๋น์์ ๋ฅ๋ธ๋ด๋๋ก ๋นํ.
8-10์ผ์ฐจ: 3์ผ๊ฐ ๋ฅ๋ธ๋ด๋ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ๋ฅ๋ธ๋ด๋์์ ์๊ทธ๋ ๋ธ๋ก ๋นํ.
10-15์ผ์ฐจ: 6์ผ๊ฐ ์๊ทธ๋ ๋ธ ๋ฐฉ๋ฌธ.
15์ผ์ฐจ: ์๊ทธ๋ ๋ธ์์ ๋ถ๋คํ์คํธ๋ก ๋นํ.
15-17์ผ์ฐจ: 3์ผ๊ฐ ๋ถ๋คํ์คํธ ๋ฐฉ๋ฌธ.
17์ผ์ฐจ: ๋ถ๋คํ์คํธ์์ ํ๋ผํ๋ก ๋นํ.
17-21์ผ์ฐจ: 5์ผ๊ฐ ํ๋ผํ ๋ฐฉ๋ฌธ.
|
You plan to visit 6 cities in Europe for a total of 21 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'll spend 4 days in Cologne. You'll visit Zagreb for 6 days. You'll spend 5 days in Vienna. You'll be traveling to Prague for 5 days. You must be in Prague between days 18-20. You'll be traveling to Ljubljana for 3 days. You will be in Budapest for 3 days.
Here are the cities that have direct flights: Vienna and Cologne, Ljubljana and Vienna, Prague and Budapest, Zagreb and Budapest, Ljubljana and Zagreb.
Plan a trip to visit six cities in 21 days with direct flights.
|
Days 1-4: Visit Cologne for 4 days.
Day 4: Fly from Cologne to Vienna.
Days 4-8: Visit Vienna for 5 days.
Day 8: Fly from Vienna to Ljubljana.
Days 8-10: Visit Ljubljana for 3 days.
Day 10: Fly from Ljubljana to Zagreb.
Days 10-15: Visit Zagreb for 6 days.
Day 15: Fly from Zagreb to Budapest.
Days 15-17: Visit Budapest for 3 days.
Day 17: Fly from Budapest to Prague.
Days 17-21: Visit Prague for 5 days.
|
๋ณ์ ์ ์:
K: ์พฐ๋ฅธ, Z: ์๊ทธ๋ ๋ธ, V: ๋น, P: ํ๋ผํ, L: ๋ฅ๋ธ๋ด๋, B: ๋ถ๋คํ์คํธ
a_K: ์พฐ๋ฅธ ๋์ฐฉ์ผ, d_K: ์พฐ๋ฅธ ์ถ๋ฐ์ผ
a_Z: ์๊ทธ๋ ๋ธ ๋์ฐฉ์ผ, d_Z: ์๊ทธ๋ ๋ธ ์ถ๋ฐ์ผ
a_V: ๋น ๋์ฐฉ์ผ, d_V: ๋น ์ถ๋ฐ์ผ
a_P: ํ๋ผํ ๋์ฐฉ์ผ, d_P: ํ๋ผํ ์ถ๋ฐ์ผ
a_L: ๋ฅ๋ธ๋ด๋ ๋์ฐฉ์ผ, d_L: ๋ฅ๋ธ๋ด๋ ์ถ๋ฐ์ผ
a_B: ๋ถ๋คํ์คํธ ๋์ฐฉ์ผ, d_B: ๋ถ๋คํ์คํธ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_K - a_K + 1 = 4
d_Z - a_Z + 1 = 6
d_V - a_V + 1 = 5
d_P - a_P + 1 = 5
d_L - a_L + 1 = 3
d_B - a_B + 1 = 3
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_K, d_Z, d_V, d_P, d_L, d_B) - min(a_K, a_Z, a_V, a_P, a_L, a_B) + 1 = 21
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[18, 20] โ [a_P, d_P]
์งํญํธ์ด ์๋ ๋์:
(V โ K), (L โ V), (P โ B), (Z โ B), (L โ Z)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ์พฐ๋ฅธ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ์พฐ๋ฅธ์์ ๋น์ผ๋ก ๋นํ.
4-8์ผ์ฐจ: 5์ผ๊ฐ ๋น ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ๋น์์ ๋ฅ๋ธ๋ด๋๋ก ๋นํ.
8-10์ผ์ฐจ: 3์ผ๊ฐ ๋ฅ๋ธ๋ด๋ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ๋ฅ๋ธ๋ด๋์์ ์๊ทธ๋ ๋ธ๋ก ๋นํ.
10-15์ผ์ฐจ: 6์ผ๊ฐ ์๊ทธ๋ ๋ธ ๋ฐฉ๋ฌธ.
15์ผ์ฐจ: ์๊ทธ๋ ๋ธ์์ ๋ถ๋คํ์คํธ๋ก ๋นํ.
15-17์ผ์ฐจ: 3์ผ๊ฐ ๋ถ๋คํ์คํธ ๋ฐฉ๋ฌธ.
17์ผ์ฐจ: ๋ถ๋คํ์คํธ์์ ํ๋ผํ๋ก ๋นํ.
17-21์ผ์ฐจ: 5์ผ๊ฐ ํ๋ผํ ๋ฐฉ๋ฌธ.
|
64
|
์ ๋ฝ
| 6
|
์ง์ ์์ฑ
|
์ด 18์ผ ๋์ ์ ๋ฝ 6๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ๋ง๋๋ฆฌ๋์ ์ด์คํ๋ถ์ ๊ฐ๊ฐ 3์ผ๊ฐ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. ์ฌํ 17์ผ์ฐจ์ ์ด์คํ๋ถ์์ ์ถ๊ตฌ ๊ฒฝ๊ธฐ๋ฅผ ์ง๊ดํ ๊ฒ์
๋๋ค. ๋ฐ์ ค, ํ๋ฆฌ, ์ํ
๋ค์ ๊ฐ๊ฐ 4์ผ๊ฐ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. ์ฌํ 4์ผ์ฐจ์ 6์ผ์ฐจ์ ํ๋ฆฌ์์ ํจ์
์ผ์ ์ฐธ์ํ ๊ฒ์
๋๋ค. ๋ก๋ง๋ฅผ 5์ผ๊ฐ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. 10์ผ๊ณผ 12์ผ ์ฌ์ด์ ๋ก๋ง์์ ์น๊ตฌ์ ๋ง๋๊ธฐ๋ก ํ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ก๋ง์ ์ด์คํ๋ถ, ๋ง๋๋ฆฌ๋์ ํ๋ฆฌ, ๋ก๋ง์ ํ๋ฆฌ, ์ํ
๋ค์ ์ด์คํ๋ถ, ํ๋ฆฌ์ ๋ฐ์ ค, ์ด์คํ๋ถ๊ณผ ํ๋ฆฌ, ๋ฐ์ ค๊ณผ ๋ก๋ง, ๋ก๋ง์ ์ํ
๋ค.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 18์ผ ๋์ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋ง๋๋ฆฌ๋ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋ง๋๋ฆฌ๋์์ ํ๋ฆฌ๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ํ๋ฆฌ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ํ๋ฆฌ์์ ๋ฐ์ ค๋ก ๋นํ.
6-9์ผ์ฐจ: 4์ผ๊ฐ ๋ฐ์ ค ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ๋ฐ์ ค์์ ๋ก๋ง๋ก ๋นํ.
9-13์ผ์ฐจ: 5์ผ๊ฐ ๋ก๋ง ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ๋ก๋ง์์ ์ํ
๋ค๋ก ๋นํ.
13-16์ผ์ฐจ: 4์ผ๊ฐ ์ํ
๋ค ๋ฐฉ๋ฌธ.
16์ผ์ฐจ: ์ํ
๋ค์์ ์ด์คํ๋ถ๋ก ๋นํ.
16-18์ผ์ฐจ: 3์ผ๊ฐ ์ด์คํ๋ถ ๋ฐฉ๋ฌธ.
|
You plan to visit 6 cities in Europe for a total of 18 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'll visit Madrid and Istanbul for 3 days each. On day 17 of your trip, you will attend a football match in Istanbul. You'll visit Basel, Paris, and Athens for 4 days each. You'll attend a fashion show in Paris on days 4 and 6. You will visit Rome for 5 days. You plan to meet with a friend in Rome between the 10th and 12th.
Here are the cities that have direct flights: Rome and Istanbul, Madrid and Paris, Rome and Paris, Athens and Istanbul, Paris and Basel, Istanbul and Paris, Basel and Rome, Rome and Athens.
Plan a trip to visit six cities in 18 days using direct flights.
|
Days 1-3: Visit Madrid for 3 days.
Day 3: Fly from Madrid to Paris.
Days 3-6: Visit Paris for 4 days.
Day 6: Fly from Paris to Basel.
Days 6-9: Visit Basel for 4 days.
Day 9: Fly from Basel to Rome.
Days 9-13: Visit Rome for 5 days.
Day 13: Fly from Rome to Athens.
Days 13-16: Visit Athens for 4 days.
Day 16: Fly from Athens to Istanbul.
Days 16-18: Visit Istanbul for 3 days.
|
๋ณ์ ์ ์:
M: ๋ง๋๋ฆฌ๋, I: ์ด์คํ๋ถ, B: ๋ฐ์ ค, P: ํ๋ฆฌ, A: ์ํ
๋ค, R: ๋ก๋ง
a_M: ๋ง๋๋ฆฌ๋ ๋์ฐฉ์ผ, d_M: ๋ง๋๋ฆฌ๋ ์ถ๋ฐ์ผ
a_I: ์ด์คํ๋ถ ๋์ฐฉ์ผ, d_I: ์ด์คํ๋ถ ์ถ๋ฐ์ผ
a_B: ๋ฐ์ ค ๋์ฐฉ์ผ, d_B: ๋ฐ์ ค ์ถ๋ฐ์ผ
a_P: ํ๋ฆฌ ๋์ฐฉ์ผ, d_P: ํ๋ฆฌ ์ถ๋ฐ์ผ
a_A: ์ํ
๋ค ๋์ฐฉ์ผ, d_A: ์ํ
๋ค ์ถ๋ฐ์ผ
a_R: ๋ก๋ง ๋์ฐฉ์ผ, d_R: ๋ก๋ง ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_M - a_M + 1 = 3
d_I - a_I + 1 = 3
d_B - a_B + 1 = 4
d_P - a_P + 1 = 4
d_A - a_A + 1 = 4
d_R - a_R + 1 = 5
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_M, d_I, d_B, d_P, d_A, d_R) - min(a_M, a_I, a_B, a_P, a_A, a_R) + 1 = 18
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
a_I โค 17 โค d_I
{4, 6} โ [a_P, d_P]
[10, 12] โฉ [a_R, d_R] โ โ
์งํญํธ์ด ์๋ ๋์:
(R โ I), (M โ P), (R โ P), (A โ I), (P โ B), (I โ P), (B โ R), (R โ A)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋ง๋๋ฆฌ๋ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋ง๋๋ฆฌ๋์์ ํ๋ฆฌ๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ํ๋ฆฌ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ํ๋ฆฌ์์ ๋ฐ์ ค๋ก ๋นํ.
6-9์ผ์ฐจ: 4์ผ๊ฐ ๋ฐ์ ค ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ๋ฐ์ ค์์ ๋ก๋ง๋ก ๋นํ.
9-13์ผ์ฐจ: 5์ผ๊ฐ ๋ก๋ง ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ๋ก๋ง์์ ์ํ
๋ค๋ก ๋นํ.
13-16์ผ์ฐจ: 4์ผ๊ฐ ์ํ
๋ค ๋ฐฉ๋ฌธ.
16์ผ์ฐจ: ์ํ
๋ค์์ ์ด์คํ๋ถ๋ก ๋นํ.
16-18์ผ์ฐจ: 3์ผ๊ฐ ์ด์คํ๋ถ ๋ฐฉ๋ฌธ.
|
65
|
์ ๋ฝ
| 3
|
์ง์ ์์ฑ
|
์ด 12์ผ ๋์ ์ ๋ฝ 3๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์ฅ์คํผ๋์์ 4์ผ๊ฐ ๋จธ๋ฌผ๊ณ ์ ํฉ๋๋ค. ์ฌํ 3์ผ์ฐจ์ ์ฅ์คํผ๋ ๋ํ๊ต ํฌ์ด๋ฅผ ์์ฝํด๋์์ต๋๋ค. ๋์ค์์ 5์ผ๊ฐ ํด์์ ์ฆ๊ธฐ๊ณ ์ถ์ต๋๋ค. 5์ผ ๋์ ์ทจ๋ฆฌํ๋ฅผ ๋ฐฉ๋ฌธํ ์์ ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋์ค์ ์ฅ์คํผ๋, ์ทจ๋ฆฌํ์ ๋์ค.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 12์ผ ๋์ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ์ฅ์คํผ๋ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ์ฅ์คํผ๋์์ ๋์ค๋ก ๋นํ.
4-8์ผ์ฐจ: 5์ผ๊ฐ ๋์ค ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ๋์ค์์ ์ทจ๋ฆฌํ๋ก ๋นํ.
8-12์ผ์ฐจ: 5์ผ๊ฐ ์ทจ๋ฆฌํ ๋ฐฉ๋ฌธ.
|
You plan to visit 3 cities in Europe for a total of 11 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to spend 4 days in Oxford. You've booked a tour of Oxford University for day 3 of your trip. You want to spend 5 days relaxing in Nice. You plan to visit Zurich on the 5th day.
Here are the cities that have direct flights: Nice and Oxford, Zurich and Nice.
Plan a trip to visit the three cities in 12 days using direct flights.
|
Days 1-4: Visit Oxford for 4 days.
Day 4: Fly from Oxford to Nice.
Days 4-8: Visit Nice for 5 days.
Day 8: Fly from Nice to Zurich.
Days 8-12: Visit Zurich for 5 days.
|
๋ณ์ ์ ์:
O: ์ฅ์คํผ๋, N: ๋์ค, Z: ์ทจ๋ฆฌํ
a_O: ์ฅ์คํผ๋ ๋์ฐฉ์ผ, d_O: ์ฅ์คํผ๋ ์ถ๋ฐ์ผ
a_N: ๋์ค ๋์ฐฉ์ผ, d_N: ๋์ค ์ถ๋ฐ์ผ
a_Z: ์ทจ๋ฆฌํ ๋์ฐฉ์ผ, d_Z: ์ทจ๋ฆฌํ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_O - a_O + 1 = 4
d_N - a_N + 1 = 5
d_Z - a_Z + 1 = 5
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_O, d_N, d_Z) - min(a_O, a_N, a_Z) + 1 = 12
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
a_O โค 3 โค d_O
์งํญํธ์ด ์๋ ๋์:
(N โ O), (Z โ N)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ์ฅ์คํผ๋ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ์ฅ์คํผ๋์์ ๋์ค๋ก ๋นํ.
4-8์ผ์ฐจ: 5์ผ๊ฐ ๋์ค ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ๋์ค์์ ์ทจ๋ฆฌํ๋ก ๋นํ.
8-12์ผ์ฐจ: 5์ผ๊ฐ ์ทจ๋ฆฌํ ๋ฐฉ๋ฌธ.
|
66
|
์ ๋ฝ
| 4
|
์ง์ ์์ฑ
|
์ด 14์ผ ๋์ ์ ๋ฝ 4๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์ํ
๋ค์์ 5์ผ๊ฐ ๋จธ๋ฌด๋ฅด๊ณ ์ ํฉ๋๋ค. ์์นด๋ผ์์๋ 5์ผ๊ฐ ๋จธ๋ฌด๋ฅด๊ณ ์ ํฉ๋๋ค. ๋ฏผ์คํฌ์์๋ 3์ผ ๋ณด๋ด๋ ค๊ณ ํฉ๋๋ค. ๋ง๋ฆฌ์ฐํด์์๋ 4์ผ์ ๋ณด๋ผ ๊ฒ์
๋๋ค. ๋๋ฒ์งธ ์ฌํ์ง๋ ๋ง๋ฆฌ์ฐํด์ด ๋์์ผ๋ฉด ์ข๊ฒ ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ์์ผ๋ผ์ ์ํ
๋ค, ๋ง๋ฆฌ์ฐํด๊ณผ ๋ฏผ์คํฌ, ๋ง๋ฆฌ์ฐํด๊ณผ ์์นด๋ผ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 14์ผ ๋์ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋ฏผ์คํฌ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋ฏผ์คํฌ์์ ๋ง๋ฆฌ์ฐํด๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ๋ง๋ฆฌ์ฐํด ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋ง๋ฆฌ์ฐํด์์ ์์นด๋ผ๋ก ๋นํ.
6-10์ผ์ฐจ: 5์ผ๊ฐ ์์นด๋ผ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ์์นด๋ผ์์ ์ํ
๋ค๋ก ๋นํ.
10-14์ผ์ฐจ: 5์ผ๊ฐ ์ํ
๋ค ๋ฐฉ๋ฌธ.
|
You plan to visit 4 cities in Europe for a total of 14 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You plan to spend 5 days in Athens. You'll also spend 5 days in Ankara. You'll spend 3 days in Minsk. You'd like to spend 4 days in Mariupol. You'd like your second trip to be to Mariupol.
Here are the cities that have direct flights: Ankara and Athens, Mariupol and Minsk, Mariupol and Ankara.
Plan a trip to visit four cities in 14 days using direct flights.
|
Days 1-3: Visit Minsk for 3 days.
Day 3: Fly from Minsk to Mariupol.
Days 3-6: Visit Mariupol for 4 days.
Day 6: Fly from Mariupol to Ankara.
Days 6-10: Visit Ankara for 5 days.
Day 10: Fly from Ankara to Athens.
Days 10-14: Visit Athens for 5 days.
|
๋ณ์ ์ ์:
A: ์ํ
๋ค, K: ์์นด๋ผ, N: ๋ฏผ์คํฌ, M: ๋ง๋ฆฌ์ฐํด
a_A: ์ํ
๋ค ๋์ฐฉ์ผ, d_A: ์ํ
๋ค ์ถ๋ฐ์ผ
a_K: ์์นด๋ผ ๋์ฐฉ์ผ, d_K: ์์นด๋ผ ์ถ๋ฐ์ผ
a_N: ๋ฏผ์คํฌ ๋์ฐฉ์ผ, d_N: ๋ฏผ์คํฌ ์ถ๋ฐ์ผ
a_M: ๋ง๋ฆฌ์ฐํด ๋์ฐฉ์ผ, d_M: ๋ง๋ฆฌ์ฐํด ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_A - a_A + 1 = 5
d_K - a_K + 1 = 5
d_N - a_N + 1 = 3
d_M - a_M + 1 = 4
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_A, d_K, d_N, d_M) - min(a_A, a_K, a_N, a_M) + 1 = 14
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
a_M = min(a_A, a_K, a_N, a_M) + 1
์งํญํธ์ด ์๋ ๋์:
(K โ A), (M โ N), (M โ K)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋ฏผ์คํฌ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋ฏผ์คํฌ์์ ๋ง๋ฆฌ์ฐํด๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ๋ง๋ฆฌ์ฐํด ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋ง๋ฆฌ์ฐํด์์ ์์นด๋ผ๋ก ๋นํ.
6-10์ผ์ฐจ: 5์ผ๊ฐ ์์นด๋ผ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ์์นด๋ผ์์ ์ํ
๋ค๋ก ๋นํ.
10-14์ผ์ฐจ: 5์ผ๊ฐ ์ํ
๋ค ๋ฐฉ๋ฌธ.
|
67
|
์ ๋ฝ
| 5
|
์ง์ ์์ฑ
|
์ด 17์ผ ๋์ ์ ๋ฝ 5๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ๋ถ๋คํ์คํธ์์ 5์ผ์ ๋ณด๋ผ ๊ฒ์
๋๋ค. ์ํผ์์์ 2์ผ์ ๋จธ๋ฌผ ๊ฒ์
๋๋ค. 1-2์ผ ์ฌ์ด์๋ ์ํผ์์ ์์ ๊ฒ์
๋๋ค. ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ์์ 4์ผ์ ๋ณด๋ด๋ ค๊ณ ํฉ๋๋ค. ๋ฒ ์ค๊ทธ๋ผ๋์์ 3์ผ๊ฐ ๋จธ๋ฌผ ์์ ์
๋๋ค. 7์ผ ๋์ ๋ธ๋ฅด๋
ธ์ ์์ ์์ ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ธ๋ฅด๋
ธ์ ๋ถ๋คํ์คํธ, ๋ฒ ์ค๊ทธ๋ผ๋์ ์ํผ์, ๋ถ๋คํ์คํธ์ ๋ฒ ์ค๊ทธ๋ผ๋, ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ์ ๋ถ๋คํ์คํธ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 17์ผ ๋์ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ์ํผ์ ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ์ํผ์์์ ๋ฒ ์ค๊ทธ๋ผ๋๋ก ๋นํ.
2-4์ผ์ฐจ: 3์ผ๊ฐ ๋ฒ ์ค๊ทธ๋ผ๋ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ๋ฒ ์ค๊ทธ๋ผ๋์์ ๋ถ๋คํ์คํธ๋ก ๋นํ.
4-8์ผ์ฐจ: 5์ผ๊ฐ ๋ถ๋คํ์คํธ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ๋ถ๋คํ์คํธ์์ ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ๋ก ๋นํ.
8-11์ผ์ฐจ: 4์ผ๊ฐ ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ์์ ๋ธ๋ฅด๋
ธ๋ก ๋นํ.
11-17์ผ์ฐจ: 7์ผ๊ฐ ๋ธ๋ฅด๋
ธ ๋ฐฉ๋ฌธ.
|
You plan to visit 5 cities in Europe for a total of 17 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'll spend 5 days in Budapest. You'll spend 2 days in Sofia. You'll be in Sofia between days 1-2. You'll spend 4 days in Bratislava. You're going to spend 3 days in Belgrade. You'll be in Brno for 7 days.
Here are the cities that have direct flights: Brno and Budapest, Belgrade and Sofia, Budapest and Belgrade, Bratislava and Budapest.
Plan a trip to visit five cities in 17 days using direct flights.
|
Day 1-2: Visit Sofia for 2 days.
Day 2: Fly from Sofia to Belgrade.
Days 2-4: Visit Belgrade for 3 days.
Day 4: Fly from Belgrade to Budapest.
Days 4-8: Visit Budapest for 5 days.
Day 8: Fly from Budapest to Bratislava.
Days 8-11: Visit Bratislava for 4 days.
Day 11: Fly from Bratislava to Brno.
Days 11-17: Visit Brno for 7 days.
|
๋ณ์ ์ ์:
Bp: ๋ถ๋คํ์คํธ, S: ์ํผ์, Br: ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ, Be: ๋ฒ ์ค๊ทธ๋ผ๋, Bn: ๋ธ๋ฅด๋
ธ
a_Bp: ๋ถ๋คํ์คํธ ๋์ฐฉ์ผ, d_Bp: ๋ถ๋คํ์คํธ ์ถ๋ฐ์ผ
a_S: ์ํผ์ ๋์ฐฉ์ผ, d_S: ์ํผ์ ์ถ๋ฐ์ผ
a_Br: ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ ๋์ฐฉ์ผ, d_Br: ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ ์ถ๋ฐ์ผ
a_Be: ๋ฒ ์ค๊ทธ๋ผ๋ ๋์ฐฉ์ผ, d_Be: ๋ฒ ์ค๊ทธ๋ผ๋ ์ถ๋ฐ์ผ
a_Bn: ๋ธ๋ฅด๋
ธ ๋์ฐฉ์ผ, d_Bn: ๋ธ๋ฅด๋
ธ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_Bp - a_Bp + 1 = 5
d_S - a_S + 1 = 2
d_Br - a_Br + 1 = 4
d_Be - a_Be + 1 = 3
d_Bn - a_Bn + 1 = 7
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_Bp, d_S, d_Br, d_Be, d_Bn) - min(a_Bp, a_S, a_Br, a_Be, a_Bn) + 1 = 17
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[1, 2] โฉ [a_S, d_S] โ โ
์งํญํธ์ด ์๋ ๋์:
(Bn โ Bp), (Be โ S), (Bp โ Be), (Br โ Bp)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ์ํผ์ ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ์ํผ์์์ ๋ฒ ์ค๊ทธ๋ผ๋๋ก ๋นํ.
2-4์ผ์ฐจ: 3์ผ๊ฐ ๋ฒ ์ค๊ทธ๋ผ๋ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ๋ฒ ์ค๊ทธ๋ผ๋์์ ๋ถ๋คํ์คํธ๋ก ๋นํ.
4-8์ผ์ฐจ: 5์ผ๊ฐ ๋ถ๋คํ์คํธ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ๋ถ๋คํ์คํธ์์ ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ๋ก ๋นํ.
8-11์ผ์ฐจ: 4์ผ๊ฐ ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ๋ธ๋ผํฐ์ฌ๋ผ๋ฐ์์ ๋ธ๋ฅด๋
ธ๋ก ๋นํ.
11-17์ผ์ฐจ: 7์ผ๊ฐ ๋ธ๋ฅด๋
ธ ๋ฐฉ๋ฌธ.
|
68
|
์ ๋ฝ
| 6
|
์ง์ ์์ฑ
|
์ด 20์ผ ๋์ ์ ๋ฝ 6๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ๋ฃฉ์
๋ถ๋ฅดํฌ์์ 2์ผ ๋์ ์ฌํ์ ์ฆ๊ธฐ๊ณ ์ถ์ต๋๋ค. 7์ผ ๋์ ๋ชฝํธ๋ขฐ์ ์์ ์์ ์
๋๋ค. 16-18์ผ ์ฌ์ด์ ๋ชฝํธ๋ขฐ์์ ์งํ๋๋ ์ฌ์ฆ ํ์คํฐ๋ฒ์ ์ฐธ์ํ ๊ฒ์
๋๋ค. ์ฝํํ๊ฒ์์ 5์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. ํจํธ์์๋ 5์ผ์ ์ฌํํ๋ ค๊ณ ํฉ๋๋ค. ๋ธ๋ ๋ฉ์ 3์ผ๊ฐ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. ์์คํ
๋ฅด๋ด์์๋ 3์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ธ๋ ๋ฉ๊ณผ ์์คํ
๋ฅด๋ด, ์ฝํํ๊ฒ๊ณผ ๋ธ๋ ๋ฉ, ํจํธ์ ๋ฃฉ์
๋ถ๋ฅดํฌ, ์์คํ
๋ฅด๋ด๊ณผ ํจํธ, ๋ฃฉ์
๋ถ๋ฅดํฌ์ ๋ชฝํธ๋ขฐ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 20์ผ ๋์ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ์ฝํํ๊ฒ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ์ฝํํ๊ฒ์์ ๋ธ๋ ๋ฉ์ผ๋ก ๋นํ.
5-7์ผ์ฐจ: 3์ผ๊ฐ ๋ธ๋ ๋ฉ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ๋ธ๋ ๋ฉ์์ ์์คํ
๋ฅด๋ด์ผ๋ก ๋นํ.
7-9์ผ์ฐจ: 3์ผ๊ฐ ์์คํ
๋ฅด๋ด ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ์์คํ
๋ฅด๋ด์์ ํจํธ๋ก ๋นํ.
9-13์ผ์ฐจ: 5์ผ๊ฐ ํจํธ ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ํจํธ์์ ๋ฃฉ์
๋ถ๋ฅดํฌ๋ก ๋นํ.
13-14์ผ์ฐจ: 2์ผ๊ฐ ๋ฃฉ์
๋ถ๋ฅดํฌ ๋ฐฉ๋ฌธ.
14์ผ์ฐจ: ๋ฃฉ์
๋ถ๋ฅดํฌ์์ ๋ชฝํธ๋ขฐ๋ก ๋นํ.
14-20์ผ์ฐจ: 7์ผ๊ฐ ๋ชฝํธ๋ขฐ ๋ฐฉ๋ฌธ.
|
You plan to visit 6 cities in Europe for a total of 20 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'd like to spend 2 days in Luxembourg. You'll be in Montreux for 7 days. Between the 16th and 18th, you will attend a jazz festival in Montreux. You want to spend 5 days in Copenhagen. You'd also like to spend 5 days in Ghent. You'll be visiting Bremen for 3 days. You'd also like to spend 3 days in Amsterdam.
Here are the cities that have direct flights: Bremen and Amsterdam, Copenhagen and Bremen, Ghent and Luxembourg, Amsterdam and Ghent, Luxembourg and Montreux.
Plan a trip to visit six cities in 20 days using direct flights.
|
Days 1-5: Visit Copenhagen for 5 days.
Day 5: Fly from Copenhagen to Bremen.
Days 5-7: Visit Bremen for 3 days.
Day 7: Fly from Bremen to Amsterdam.
Days 7-9: Visit Amsterdam for 3 days.
Day 9: Fly from Amsterdam to Ghent.
Days 9-13: Visit Ghent for 5 days.
Day 13: Fly from Ghent to Luxembourg.
Days 13-14: Visit Luxembourg for 2 days.
Day 14: Fly from Luxembourg to Montreux.
Days 14-20: Visit Montreux for 7 days.
|
๋ณ์ ์ ์:
L: ๋ฃฉ์
๋ถ๋ฅดํฌ, M: ๋ชฝํธ๋ขฐ, C: ์ฝํํ๊ฒ, G: ํจํธ, B: ๋ธ๋ ๋ฉ, A: ์์คํ
๋ฅด๋ด
a_L: ๋ฃฉ์
๋ถ๋ฅดํฌ ๋์ฐฉ์ผ, d_L: ๋ฃฉ์
๋ถ๋ฅดํฌ ์ถ๋ฐ์ผ
a_M: ๋ชฝํธ๋ขฐ ๋์ฐฉ์ผ, d_M: ๋ชฝํธ๋ขฐ ์ถ๋ฐ์ผ
a_C: ์ฝํํ๊ฒ ๋์ฐฉ์ผ, d_C: ์ฝํํ๊ฒ ์ถ๋ฐ์ผ
a_G: ํจํธ ๋์ฐฉ์ผ, d_G: ํจํธ ์ถ๋ฐ์ผ
a_B: ๋ธ๋ ๋ฉ ๋์ฐฉ์ผ, d_B: ๋ธ๋ ๋ฉ ์ถ๋ฐ์ผ
a_A: ์์คํ
๋ฅด๋ด ๋์ฐฉ์ผ, d_A: ์์คํ
๋ฅด๋ด ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_L - a_L + 1 = 2
d_M - a_M + 1 = 7
d_C - a_C + 1 = 5
d_G - a_G + 1 = 5
d_B - a_B + 1 = 3
d_A - a_A + 1 = 3
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_L, d_M, d_C, d_G, d_B, d_A) - min(a_L, a_M, a_C, a_G, a_B, a_A) + 1 = 20
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[16, 18] โฉ [a_M, d_M] โ โ
์งํญํธ์ด ์๋ ๋์:
(B โ A), (C โ B), (G โ L), (A โ G), (L โ M)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ์ฝํํ๊ฒ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ์ฝํํ๊ฒ์์ ๋ธ๋ ๋ฉ์ผ๋ก ๋นํ.
5-7์ผ์ฐจ: 3์ผ๊ฐ ๋ธ๋ ๋ฉ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ๋ธ๋ ๋ฉ์์ ์์คํ
๋ฅด๋ด์ผ๋ก ๋นํ.
7-9์ผ์ฐจ: 3์ผ๊ฐ ์์คํ
๋ฅด๋ด ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ์์คํ
๋ฅด๋ด์์ ํจํธ๋ก ๋นํ.
9-13์ผ์ฐจ: 5์ผ๊ฐ ํจํธ ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ํจํธ์์ ๋ฃฉ์
๋ถ๋ฅดํฌ๋ก ๋นํ.
13-14์ผ์ฐจ: 2์ผ๊ฐ ๋ฃฉ์
๋ถ๋ฅดํฌ ๋ฐฉ๋ฌธ.
14์ผ์ฐจ: ๋ฃฉ์
๋ถ๋ฅดํฌ์์ ๋ชฝํธ๋ขฐ๋ก ๋นํ.
14-20์ผ์ฐจ: 7์ผ๊ฐ ๋ชฝํธ๋ขฐ ๋ฐฉ๋ฌธ.
|
69
|
์์์
| 3
|
์ง์ ์์ฑ
|
์ด 9์ผ ๋์ ์์์ 3๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์์คํ๋์์ 2์ผ๊ฐ ๋จธ๋ฌด๋ฅผ ๊ฒ์
๋๋ค. 5์ผ์ ํ์์ผํธ์์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. 4์ผ ๋์ ๋น์์ผํฌ์ ์์ ์์ ์
๋๋ค. ๊ฐ์ฅ ์ค๋ ๋จธ๋ฌผ ์ฌํ์ง๋ฅผ ์ ์ผ ๋ง์ง๋ง์ ๋ฐฉ๋ฌธํ๊ณ ์ถ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ํ์์ผํธ์ ์์คํ๋, ๋น์์ผํฌ์ ์์คํ๋.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 9์ผ ๋์ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ๋น์์ผํฌ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ๋น์์ผํฌ์์ ์์คํ๋๋ก ๋นํ.
4-5์ผ์ฐจ: 2์ผ๊ฐ ์์คํ๋ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ์์คํ๋์์ ํ์์ผํธ๋ก ๋นํ.
5-9์ผ์ฐจ: 5์ผ๊ฐ ํ์์ผํธ ๋ฐฉ๋ฌธ.
|
You plan to visit 3 cities in Asia for a total of 9 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'll be in Astana for 2 days. You'd like to spend 5 days in Tashkent. You'll be in Bishkek for 4 days. You want to visit the destination where you will be staying the longest last.
Here are the cities that have direct flights: Tashkent and Astana, Bishkek and Astana.
Plan a trip to visit all three cities in 9 days using direct flights.
|
Days 1-4: Visit Bishkek for 4 days.
Day 4: Fly from Bishkek to Astana.
Days 4-5: Visit Astana for 2 days.
Day 5: Fly from Astana to Tashkent.
Days 5-9: Visit Tashkent for 5 days.
|
๋ณ์ ์ ์:
A: ์์คํ๋, T: ํ์์ผํธ, B: ๋น์์ผํฌ
a_A: ์์คํ๋ ๋์ฐฉ์ผ, d_A: ์์คํ๋ ์ถ๋ฐ์ผ
a_T: ํ์์ผํธ ๋์ฐฉ์ผ, d_T: ํ์์ผํธ ์ถ๋ฐ์ผ
a_B: ๋น์์ผํฌ ๋์ฐฉ์ผ, d_B: ๋น์์ผํฌ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_A - a_A + 1 = 2
d_T - a_T + 1 = 5
d_B - a_B + 1 = 4
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_A, d_T, d_B) - min(a_A, a_T, a_B) + 1 = 9
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
d_T = 9 (๊ฐ์ฅ ์ค๋ ๋จธ๋ฌผ ์ฌํ์ง๋ฅผ ๋ง์ง๋ง์ ๋ฐฉ๋ฌธ)
์งํญํธ์ด ์๋ ๋์:
(T โ A), (B โ A)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ๋น์์ผํฌ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ๋น์์ผํฌ์์ ์์คํ๋๋ก ๋นํ.
4-5์ผ์ฐจ: 2์ผ๊ฐ ์์คํ๋ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ์์คํ๋์์ ํ์์ผํธ๋ก ๋นํ.
5-9์ผ์ฐจ: 5์ผ๊ฐ ํ์์ผํธ ๋ฐฉ๋ฌธ.
|
70
|
์์์
| 3
|
์ง์ ์์ฑ
|
์ด 9์ผ ๋์ ์์์ 3๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์์๊ฐ๋ฐํธ์์ 3์ผ์ ๋ณด๋ด๊ณ ์ ํฉ๋๋ค. ํ์์ผํธ์์ 6์ผ๊ฐ ๋จธ๋ฌด๋ฅผ ์์ ์
๋๋ค. ํ
ํค๋์์ 2์ผ์ ๋ณด๋ผ ๊ฒ์
๋๋ค. 8์ผ์์ 9์ผ ์ฌ์ด์ ํ
ํค๋์ ์๊ณ ์ถ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ์์๊ฐ๋ฐํธ์ ํ์์ผํธ, ํ
ํค๋๊ณผ ์์๊ฐ๋ฐํธ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 9์ผ ๋์ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-6์ผ์ฐจ: 6์ผ๊ฐ ํ์์ผํธ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ํ์์ผํธ์์ ์์๊ฐ๋ฐํธ๋ก ๋นํ.
6-8์ผ์ฐจ: 3์ผ๊ฐ ์์๊ฐ๋ฐํธ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ์์๊ฐ๋ฐํธ์์ ํ
ํค๋๋ก ๋นํ.
8-9์ผ์ฐจ: 2์ผ๊ฐ ํ
ํค๋ ๋ฐฉ๋ฌธ.
|
You plan to visit 3 cities in Asia for a total of 9 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to spend 3 days in Ashgabat. You'll spend 6 days in Tashkent. You'll spend 2 days in Tehran. You'd like to be in Tehran between the 8th and 9th.
Here are the cities that have direct flights: Ashgabat and Tashkent, Tehran and Ashgabat.
Plan a trip to visit the three cities in 9 days using direct flights.
|
Days 1-6: Visit Tashkent for 6 days.
Day 6: Fly from Tashkent to Ashgabat.
Days 6-8: Visit Ashgabat for 3 days.
Day 8: Fly from Ashgabat to Tehran.
Days 8-9: Visit Tehran for 2 days.
|
๋ณ์ ์ ์:
A: ์์๊ฐ๋ฐํธ, T: ํ์์ผํธ, E: ํ
ํค๋
a_A: ์์๊ฐ๋ฐํธ ๋์ฐฉ์ผ, d_A: ์์๊ฐ๋ฐํธ ์ถ๋ฐ์ผ
a_T: ํ์์ผํธ ๋์ฐฉ์ผ, d_T: ํ์์ผํธ ์ถ๋ฐ์ผ
a_E: ํ
ํค๋ ๋์ฐฉ์ผ, d_E: ํ
ํค๋ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_A - a_A + 1 = 3
d_T - a_T + 1 = 6
d_E - a_E + 1 = 2
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_A, d_T, d_E) - min(a_A, a_T, a_E) + 1 = 9
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[8, 9] โฉ [a_E, d_E] โ โ
์งํญํธ์ด ์๋ ๋์:
(A โ T), (E โ A)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-6์ผ์ฐจ: 6์ผ๊ฐ ํ์์ผํธ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ํ์์ผํธ์์ ์์๊ฐ๋ฐํธ๋ก ๋นํ.
6-8์ผ์ฐจ: 3์ผ๊ฐ ์์๊ฐ๋ฐํธ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ์์๊ฐ๋ฐํธ์์ ํ
ํค๋๋ก ๋นํ.
8-9์ผ์ฐจ: 2์ผ๊ฐ ํ
ํค๋ ๋ฐฉ๋ฌธ.
|
71
|
์์์
| 3
|
์ง์ ์์ฑ
|
์ด 8์ผ ๋์ ์์์ 3๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. 3์ผ๊ฐ ๋ฒ ์ด์ง์ ๊ตฌ๊ฒฝํ ๊ฒ์
๋๋ค. 3์ผ ๋์์ ๋ชจ์คํฌ๋ฐ์ ์๊ณ ์ถ์ต๋๋ค. ์ฌํ 2์ผ์ฐจ์ ๋ชจ์คํฌ๋ฐ์์ ์น๊ตฌ์ ์์ผํํฐ์ ์ฐธ์ํ๊ธฐ๋ก ํ์ต๋๋ค. ์ธ๋๋ฐํ ๋ฅด์์ 4์ผ์ ๋ณด๋ผ ๊ฒ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ์ธ๋๋ฐํ ๋ฅด์ ๋ชจ์คํฌ๋ฐ, ๋ฒ ์ด์ง๊ณผ ์ธ๋๋ฐํ ๋ฅด.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 8์ผ ๋์ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋ชจ์คํฌ๋ฐ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋ชจ์คํฌ๋ฐ์์ ์ธ๋๋ฐํ ๋ฅด๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ์ธ๋๋ฐํ ๋ฅด ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์ธ๋๋ฐํ ๋ฅด์์ ๋ฒ ์ด์ง๋ก ๋นํ.
6-8์ผ์ฐจ: 3์ผ๊ฐ ๋ฒ ์ด์ง ๋ฐฉ๋ฌธ.
|
You plan to visit 3 cities in Asia for a total of 8 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'll be in Beijing for 3 days. You'll be in Moscow for 3 days. You'll be attending a friend's birthday party in Moscow on the second day of your trip. You will spend 4 days in Ulaanbaatar.
Here are the cities that have direct flights: Ulaanbaatar and Moscow, Beijing and Ulaanbaatar.
Plan a trip to visit the three cities in 8 days using direct flights.
|
Days 1-3: Visit Moscow for 3 days.
Day 3: Fly from Moscow to Ulaanbaatar.
Days 3-6: Visit Ulaanbaatar for 4 days.
Day 6: Fly from Ulaanbaatar to Beijing.
Days 6-8: Visit Beijing for 3 days.
|
๋ณ์ ์ ์:
B: ๋ฒ ์ด์ง, M: ๋ชจ์คํฌ๋ฐ, U: ์ธ๋๋ฐํ ๋ฅด
a_B: ๋ฒ ์ด์ง ๋์ฐฉ์ผ, d_B: ๋ฒ ์ด์ง ์ถ๋ฐ์ผ
a_M: ๋ชจ์คํฌ๋ฐ ๋์ฐฉ์ผ, d_M: ๋ชจ์คํฌ๋ฐ ์ถ๋ฐ์ผ
a_U: ์ธ๋๋ฐํ ๋ฅด ๋์ฐฉ์ผ, d_U: ์ธ๋๋ฐํ ๋ฅด ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_B - a_B + 1 = 3
d_M - a_M + 1 = 3
d_U - a_U + 1 = 4
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_B, d_M, d_U) - min(a_B, a_M, a_U) + 1 = 8
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
a_M โค 2 โค d_M
์งํญํธ์ด ์๋ ๋์:
(U โ M), (B โ U)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋ชจ์คํฌ๋ฐ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋ชจ์คํฌ๋ฐ์์ ์ธ๋๋ฐํ ๋ฅด๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ์ธ๋๋ฐํ ๋ฅด ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์ธ๋๋ฐํ ๋ฅด์์ ๋ฒ ์ด์ง๋ก ๋นํ.
6-8์ผ์ฐจ: 3์ผ๊ฐ ๋ฒ ์ด์ง ๋ฐฉ๋ฌธ.
|
72
|
์์์
| 3
|
์ง์ ์์ฑ
|
์ด 10์ผ ๋์ ์์์ 3๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. 5์ผ๊ฐ ์์ธ์ ์ฌํํ ๊ฒ์
๋๋ค. 3์ผ๊ณผ 7์ผ ์ฌ์ด์๋ ์์ธ์ ์์ ๊ฒ์
๋๋ค. 4์ผ ๋์์ ์ธ๋๋ฐํ ๋ฅด์ ์๊ณ ์ถ์ต๋๋ค. 3์ผ๊ฐ ๋์ฟ์์ ๋จธ๋ฌผ ์์ ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ์ธ๋๋ฐํ ๋ฅด์ ์์ธ, ์์ธ๊ณผ ๋์ฟ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 10์ผ ๋์ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋์ฟ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋์ฟ์์ ์์ธ๋ก ๋นํ.
3-7์ผ์ฐจ: 5์ผ๊ฐ ์์ธ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ์์ธ์์ ์ธ๋๋ฐํ ๋ฅด๋ก ๋นํ.
7-10์ผ์ฐจ: 4์ผ๊ฐ ์ธ๋๋ฐํ ๋ฅด ๋ฐฉ๋ฌธ.
|
You plan to visit 3 cities in Asia for a total of 10 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You will be traveling to Seoul for 5 days. You will be in Seoul between days 3 and 7. You want to be in Ulaanbaatar for 4 days. You will be in Tokyo for 3 days.
Here are the cities that have direct flights: Ulaanbaatar and Seoul, Seoul and Tokyo.
Plan a trip to visit the three cities in 10 days using direct flights.
|
Days 1-3: Visit Tokyo for 3 days.
Day 3: Fly from Tokyo to Seoul.
Days 3-7: Visit Seoul for 5 days.
Day 7: Fly from Seoul to Ulaanbaatar.
Days 7-10: Visit Ulaanbaatar for 4 days.
|
๋ณ์ ์ ์:
S: ์์ธ, U: ์ธ๋๋ฐํ ๋ฅด, T: ๋์ฟ
a_S: ์์ธ ๋์ฐฉ์ผ, d_S: ์์ธ ์ถ๋ฐ์ผ
a_U: ์ธ๋๋ฐํ ๋ฅด ๋์ฐฉ์ผ, d_U: ์ธ๋๋ฐํ ๋ฅด ์ถ๋ฐ์ผ
a_T: ๋์ฟ ๋์ฐฉ์ผ, d_T: ๋์ฟ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_S - a_S + 1 = 5
d_U - a_U + 1 = 4
d_T - a_T + 1 = 3
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_S, d_U, d_T) - min(a_S, a_U, a_T) + 1 = 10
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[3, 7] โฉ [a_S, d_S] โ โ
์งํญํธ์ด ์๋ ๋์:
(U โ S), (S โ T)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋์ฟ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋์ฟ์์ ์์ธ๋ก ๋นํ.
3-7์ผ์ฐจ: 5์ผ๊ฐ ์์ธ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ์์ธ์์ ์ธ๋๋ฐํ ๋ฅด๋ก ๋นํ.
7-10์ผ์ฐจ: 4์ผ๊ฐ ์ธ๋๋ฐํ ๋ฅด ๋ฐฉ๋ฌธ.
|
73
|
์์์
| 4
|
์ง์ ์์ฑ
|
์ด 13์ผ ๋์ ์์์ 4๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์นดํธ๋ง๋์์ 4์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. ์ด์ฌ๋ผ๋ง๋ฐ๋์์ 3์ผ์ ๋จธ๋ฌด๋ฅผ ๊ฒ์
๋๋ค. 4์ผ ๋์ ํํธ๋ฅผ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. ๋ด๋ธ๋ฆฌ์์ 5์ผ์ ๋ณด๋ผ ๊ฒ์
๋๋ค. 3์ผ๊ณผ 5์ผ ์ฌ์ด์ ๋ด๋ธ๋ฆฌ์ ์๋ ์ฌ์์ ๋ฐฉ๋ฌธํ๊ณ ์ถ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ํํธ์ ์นดํธ๋ง๋, ๋ด๋ธ๋ฆฌ์ ์ด์ฌ๋ผ๋ง๋ฐ๋, ์นดํธ๋ง๋์ ๋ด๋ธ๋ฆฌ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 13์ผ ๋์ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ์ด์ฌ๋ผ๋ง๋ฐ๋ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ์ด์ฌ๋ผ๋ง๋ฐ๋์์ ๋ด๋ธ๋ฆฌ๋ก ๋นํ.
3-7์ผ์ฐจ: 5์ผ๊ฐ ๋ด๋ธ๋ฆฌ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ๋ด๋ธ๋ฆฌ์์ ์นดํธ๋ง๋๋ก ๋นํ.
7-10์ผ์ฐจ: 4์ผ๊ฐ ์นดํธ๋ง๋ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ์นดํธ๋ง๋์์ ํํธ๋ก ๋นํ.
10-13์ผ์ฐจ: 4์ผ๊ฐ ํํธ ๋ฐฉ๋ฌธ.
|
You plan to visit 4 cities in Asia for a total of 13 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to spend 4 days in Kathmandu. You want to spend 3 days in Islamabad. You want to spend 4 days in Thimphu. You want to spend 5 days in New Delhi. Between days 3 and 5, you want to visit a temple in New Delhi.
Here are the cities that have direct flights: Thimphu and Kathmandu, New Delhi and Islamabad, Kathmandu and New Delhi.
Plan a trip to visit four cities in 13 days using direct flights.
|
Days 1-3: Visit Islamabad for 3 days.
Day 3: Fly from Islamabad to New Delhi.
Days 3-7: Visit New Delhi for 5 days.
Day 7: Fly from New Delhi to Kathmandu.
Days 7-10: Visit Kathmandu for 4 days.
Day 10: Fly from Kathmandu to Thimphu.
Days 10-13: Visit Thimphu for 4 days.
|
๋ณ์ ์ ์:
K: ์นดํธ๋ง๋, I: ์ด์ฌ๋ผ๋ง๋ฐ๋, T: ํํธ, N: ๋ด๋ธ๋ฆฌ
a_K: ์นดํธ๋ง๋ ๋์ฐฉ์ผ, d_K: ์นดํธ๋ง๋ ์ถ๋ฐ์ผ
a_I: ์ด์ฌ๋ผ๋ง๋ฐ๋ ๋์ฐฉ์ผ, d_I: ์ด์ฌ๋ผ๋ง๋ฐ๋ ์ถ๋ฐ์ผ
a_T: ํํธ ๋์ฐฉ์ผ, d_T: ํํธ ์ถ๋ฐ์ผ
a_N: ๋ด๋ธ๋ฆฌ ๋์ฐฉ์ผ, d_N: ๋ด๋ธ๋ฆฌ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_K - a_K + 1 = 4
d_I - a_I + 1 = 3
d_T - a_T + 1 = 4
d_N - a_N + 1 = 5
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_K, d_I, d_T, d_N) - min(a_K, a_I, a_T, a_N) + 1 = 13
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[3, 5] โฉ [a_N, d_N] โ โ
์งํญํธ์ด ์๋ ๋์:
(T โ K), (N โ I), (K โ N)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ์ด์ฌ๋ผ๋ง๋ฐ๋ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ์ด์ฌ๋ผ๋ง๋ฐ๋์์ ๋ด๋ธ๋ฆฌ๋ก ๋นํ.
3-7์ผ์ฐจ: 5์ผ๊ฐ ๋ด๋ธ๋ฆฌ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ๋ด๋ธ๋ฆฌ์์ ์นดํธ๋ง๋๋ก ๋นํ.
7-10์ผ์ฐจ: 4์ผ๊ฐ ์นดํธ๋ง๋ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ์นดํธ๋ง๋์์ ํํธ๋ก ๋นํ.
10-13์ผ์ฐจ: 4์ผ๊ฐ ํํธ ๋ฐฉ๋ฌธ.
|
74
|
์์์
| 4
|
์ง์ ์์ฑ
|
์ด 11์ผ ๋์ ์์์ 4๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. 5์ผ ๋์ ๋ด๋ธ๋ฆฌ๋ฅผ ์ฌํํ ๊ฒ์
๋๋ค. 3-4์ผ์ ๋ด๋ธ๋ฆฌ์ ์๋ ์น๊ตฌ์ ์ง์ ๋จธ๋ฌด๋ฅผ ๊ฒ์
๋๋ค. ๋ฒ ์ด์ง์์ 3์ผ ๊ฐ ์ฌํ์ ํ๋ ค๊ณ ํฉ๋๋ค. 10์ผ์ ๋ฒ ์ด์ง์์ ์ ์ง์ฅ ๋๋ฃ์ ๊ทธ์ ์์ดํ๋ฅผ ๋ง๋๋ ์ฝ์์ ์ก์์ต๋๋ค. ๋คํผ๋์์ 4์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. ๋ค์นด์์ 2์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋คํผ๋์ ๋ฒ ์ด์ง, ๋ค์นด์ ๋ฒ ์ด์ง, ๋ค์นด์ ๋คํผ๋, ๋ด๋ธ๋ฆฌ์ ๋ค์นด.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 11์ผ ๋์ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ๋ด๋ธ๋ฆฌ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋ด๋ธ๋ฆฌ์์ ๋ค์นด๋ก ๋นํ.
5-6์ผ์ฐจ: 2์ผ๊ฐ ๋ค์นด ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋ค์นด์์ ๋คํผ๋๋ก ๋นํ.
6-9์ผ์ฐจ: 4์ผ๊ฐ ๋คํผ๋ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ๋คํผ๋์์ ๋ฒ ์ด์ง๋ก ๋นํ.
9-11์ผ์ฐจ: 3์ผ๊ฐ ๋ฒ ์ด์ง ๋ฐฉ๋ฌธ.
|
You plan to visit 4 cities in Asia for a total of 11 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'll be traveling to New Delhi for 5 days. On days 3-4, you'll stay at a friend's house in New Delhi. You'll spend 3 days in Beijing. You have an appointment to meet a former coworker and his wife in Beijing on the 10th. You want to spend 4 days in Nepido. You want to spend 2 days in Dhaka.
Here are the cities that have direct flights: Nepido and Beijing, Dhaka and Beijing, Dhaka and Nepido, New Delhi and Dhaka.
Plan your trip to visit four cities in 11 days with direct flights.
|
Days 1-5: Visit New Delhi for 5 days.
Day 5: Fly from New Delhi to Dhaka.
Days 5-6: Visit Dhaka for 2 days.
Day 6: Fly from Dhaka to Nepido.
Days 6-9: Visit Nepido for 4 days.
Day 9: Fly from Nepido to Beijing.
Days 9-11: Visit Beijing for 3 days.
|
๋ณ์ ์ ์:
N: ๋ด๋ธ๋ฆฌ, B: ๋ฒ ์ด์ง, P: ๋คํผ๋, D: ๋ค์นด
a_N: ๋ด๋ธ๋ฆฌ ๋์ฐฉ์ผ, d_N: ๋ด๋ธ๋ฆฌ ์ถ๋ฐ์ผ
a_B: ๋ฒ ์ด์ง ๋์ฐฉ์ผ, d_B: ๋ฒ ์ด์ง ์ถ๋ฐ์ผ
a_P: ๋คํผ๋ ๋์ฐฉ์ผ, d_P: ๋คํผ๋ ์ถ๋ฐ์ผ
a_D: ๋ค์นด ๋์ฐฉ์ผ, d_D: ๋ค์นด ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_N - a_N + 1 = 5
d_B - a_B + 1 = 3
d_P - a_P + 1 = 4
d_D - a_D + 1 = 2
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_N, d_B, d_P, d_D) - min(a_N, a_B, a_P, a_D) + 1 = 11
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
{3, 4} โ [a_N, d_N]
10 โ [a_B, d_B]
์งํญํธ์ด ์๋ ๋์:
(P โ B), (D โ B), (D โ P), (N โ D)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ๋ด๋ธ๋ฆฌ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋ด๋ธ๋ฆฌ์์ ๋ค์นด๋ก ๋นํ.
5-6์ผ์ฐจ: 2์ผ๊ฐ ๋ค์นด ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋ค์นด์์ ๋คํผ๋๋ก ๋นํ.
6-9์ผ์ฐจ: 4์ผ๊ฐ ๋คํผ๋ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ๋คํผ๋์์ ๋ฒ ์ด์ง๋ก ๋นํ.
9-11์ผ์ฐจ: 3์ผ๊ฐ ๋ฒ ์ด์ง ๋ฐฉ๋ฌธ.
|
75
|
์์์
| 4
|
์ง์ ์์ฑ
|
์ด 12์ผ ๋์ ์์์ 4๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. 5์ผ ๋์ ๋ฐฉ์ฝ์ ๋ฐฉ๋ฌธํ ์์ ์
๋๋ค. 8-10์ผ ์ฌ์ด์ ๋ฐฉ์ฝ์์ ํ๋ ๋์ ์ ํํฐ์ ์ฐธ์ํ ์์ ์
๋๋ค. 4์ผ๊ฐ ๋คํผ๋์ ์๊ณ ์ถ์ต๋๋ค. ๋น์ํฐ์๊ณผ ํ๋ํ์ ๊ฐ๊ฐ 3์ผ๊ฐ ๋จธ๋ฌด๋ฅด๊ณ ์ถ์ต๋๋ค. ํ๋ํ์ด ๊ฐ์ฅ ๋ง์ง๋ง ์ฌํ์ง์์ผ๋ฉด ์ข๊ฒ ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ฐฉ์ฝ๊ณผ ํ๋ํ, ๋น์ํฐ์๊ณผ ๋ฐฉ์ฝ, ๋น์ํฐ์๊ณผ ํ๋ํ, ๋น์ํฐ์๊ณผ ๋คํผ๋.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 12์ผ ๋์ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ๋คํผ๋ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ๋คํผ๋์์ ๋น์ํฐ์์ผ๋ก ๋นํ.
4-6์ผ์ฐจ: 3์ผ๊ฐ ๋น์ํฐ์ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋น์ํฐ์์์ ๋ฐฉ์ฝ๋ก ๋นํ.
6-10์ผ์ฐจ: 5์ผ๊ฐ ๋ฐฉ์ฝ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ๋ฐฉ์ฝ์์ ํ๋ํ๋ก ๋นํ.
10-12์ผ์ฐจ: 3์ผ๊ฐ ํ๋ํ ๋ฐฉ๋ฌธ.
|
You plan to visit 4 cities in Asia for a total of 12 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'll be in Bangkok for 5 days. You're attending a dj party in Bangkok between days 8-10. You want to be in Naypyidaw for 4 days. You want to be in Vientiane and Phnom Penh for 3 days each. You would like Phnom Penh to be your last destination.
Here are the cities that have direct flights: Bangkok and Phnom Penh, Vientiane and Bangkok, Vientiane and Phnom Penh, Vientiane and Naypyidaw.
Plan a trip to visit four cities in 12 days with direct flights.
|
Days 1-4: Visit Naypyidaw for 4 days.
Day 4: Fly from Naypyidaw to Vientiane.
Days 4-6: Visit Vientiane for 3 days.
Day 6: Fly from Vientiane to Bangkok.
Days 6-10: Visit Bangkok for 5 days.
Day 10: Fly from Bangkok to Phnom Penh.
Days 10-12: Visit Phnom Penh for 3 days.
|
๋ณ์ ์ ์:
B: ๋ฐฉ์ฝ, N: ๋คํผ๋, V: ๋น์ํฐ์, P: ํ๋ํ
a_B: ๋ฐฉ์ฝ ๋์ฐฉ์ผ, d_B: ๋ฐฉ์ฝ ์ถ๋ฐ์ผ
a_N: ๋คํผ๋ ๋์ฐฉ์ผ, d_N: ๋คํผ๋ ์ถ๋ฐ์ผ
a_V: ๋น์ํฐ์ ๋์ฐฉ์ผ, d_V: ๋น์ํฐ์ ์ถ๋ฐ์ผ
a_P: ํ๋ํ ๋์ฐฉ์ผ, d_P: ํ๋ํ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_B - a_B + 1 = 5
d_N - a_N + 1 = 4
d_V - a_V + 1 = 3
d_P - a_P + 1 = 3
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_B, d_N, d_V, d_P) - min(a_B, a_N, a_V, a_P) + 1 = 12
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[8, 10] โฉ [a_B, d_B] โ โ
max(d_B, d_N, d_V) < a_P
์งํญํธ์ด ์๋ ๋์:
(B โ P), (V โ B), (V โ P), (V โ N)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ๋คํผ๋ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ๋คํผ๋์์ ๋น์ํฐ์์ผ๋ก ๋นํ.
4-6์ผ์ฐจ: 3์ผ๊ฐ ๋น์ํฐ์ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋น์ํฐ์์์ ๋ฐฉ์ฝ๋ก ๋นํ.
6-10์ผ์ฐจ: 5์ผ๊ฐ ๋ฐฉ์ฝ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ๋ฐฉ์ฝ์์ ํ๋ํ๋ก ๋นํ.
10-12์ผ์ฐจ: 3์ผ๊ฐ ํ๋ํ ๋ฐฉ๋ฌธ.
|
76
|
์์์
| 4
|
์ง์ ์์ฑ
|
์ด 12์ผ ๋์ ์์์ 4๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ํ์ด๋ฒ ์ด์์ 5์ผ์ ๋ณด๋ด๋ ค๊ณ ํฉ๋๋ค. 9์ผ๊ณผ 11์ผ ์ฌ์ด์ ํ์ด๋ฒ ์ด์์ ํฌ์ด๋ฅผ ์์ฝํด๋์์ต๋๋ค. 3์ผ๊ฐ ์์ธ์ ๋ฐฉ๋ฌธํ๋ ค ํฉ๋๋ค. ์ฌํ 3-4์ผ์ฐจ์ ์์ธ์ ์๋ ๋ณธ์ง์ ๋ฐฉ๋ฌธํ๋ ค๊ณ ํฉ๋๋ค. ๋์ฟ๋ 3์ผ๊ฐ ๋จธ๋ฌด๋ ค๊ณ ํฉ๋๋ค. ๋ฒ ์ด์ง์์ 4์ผ์ ๋ณด๋ผ ๊ฒ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ฒ ์ด์ง๊ณผ ์์ธ, ๋์ฟ์ ์์ธ, ํ์ด๋ฒ ์ด์ ์์ธ, ํ์ด๋ฒ ์ด์ ๋ฒ ์ด์ง.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 12์ผ ๋์ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋์ฟ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋์ฟ์์ ์์ธ๋ก ๋นํ.
3-5์ผ์ฐจ: 3์ผ๊ฐ ์์ธ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ์์ธ์์ ๋ฒ ์ด์ง์ผ๋ก ๋นํ.
5-8์ผ์ฐจ: 4์ผ๊ฐ ๋ฒ ์ด์ง ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ๋ฒ ์ด์ง์์ ํ์ด๋ฒ ์ด๋ก ๋นํ.
8-12์ผ์ฐจ: 5์ผ๊ฐ ํ์ด๋ฒ ์ด ๋ฐฉ๋ฌธ.
|
You plan to visit 4 cities in Asia for a total of 12 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You plan to spend 5 days in Taipei. You've booked a tour in Taipei between the 9th and 11th. You plan to visit your home in Seoul for 3 days. You'll visit your home in Seoul on days 3-4 of your trip. You're also planning to spend 3 days in Tokyo. You will spend 4 days in Beijing.
Here are the cities that have direct flights: Beijing and Seoul, Tokyo and Seoul, Taipei and Seoul, Taipei and Beijing.
Plan a trip to visit four cities in 12 days with direct flights.
|
Days 1-3: Visit Tokyo for 3 days.
Day 3: Fly from Tokyo to Seoul.
Days 3-5: Visit Seoul for 3 days.
Day 5: Fly from Seoul to Beijing.
Days 5-8: Visit Beijing for 4 days.
Day 8: Fly from Beijing to Taipei.
Days 8-12: Visit Taipei for 5 days.
|
๋ณ์ ์ ์:
T: ํ์ด๋ฒ ์ด, S: ์์ธ, D: ๋์ฟ, B: ๋ฒ ์ด์ง
a_T: ํ์ด๋ฒ ์ด ๋์ฐฉ์ผ, d_T: ํ์ด๋ฒ ์ด ์ถ๋ฐ์ผ
a_S: ์์ธ ๋์ฐฉ์ผ, d_S: ์์ธ ์ถ๋ฐ์ผ
a_D: ๋์ฟ ๋์ฐฉ์ผ, d_D: ๋์ฟ ์ถ๋ฐ์ผ
a_B: ๋ฒ ์ด์ง ๋์ฐฉ์ผ, d_B: ๋ฒ ์ด์ง ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_T - a_T + 1 = 5
d_S - a_S + 1 = 3
d_D - a_D + 1 = 3
d_B - a_B + 1 = 4
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_T, d_S, d_D, d_B) - min(a_T, a_S, a_D, a_B) + 1 = 12
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[9, 11] โฉ [a_T, d_T] โ โ
{3, 4} โ [a_S, d_S]
์งํญํธ์ด ์๋ ๋์:
(B โ S), (D โ S), (T โ S), (T โ B)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋์ฟ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋์ฟ์์ ์์ธ๋ก ๋นํ.
3-5์ผ์ฐจ: 3์ผ๊ฐ ์์ธ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ์์ธ์์ ๋ฒ ์ด์ง์ผ๋ก ๋นํ.
5-8์ผ์ฐจ: 4์ผ๊ฐ ๋ฒ ์ด์ง ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ๋ฒ ์ด์ง์์ ํ์ด๋ฒ ์ด๋ก ๋นํ.
8-12์ผ์ฐจ: 5์ผ๊ฐ ํ์ด๋ฒ ์ด ๋ฐฉ๋ฌธ.
|
77
|
์์์
| 5
|
์ง์ ์์ฑ
|
์ด 16์ผ ๋์ ์์์ 5๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. 5์ผ ๋์ ์์นด๋ฅดํ์ ๋จธ๋ฌผ ๊ฒ์
๋๋ค. ๋ง๋๋ผ์์๋ 5์ผ์ ๋จธ๋ฌผ๊ณ ์ถ์ต๋๋ค. 13์ผ๊ณผ 15์ผ ์ฌ์ด์ ๋ง๋๋ผ ํฌ์ด๋ฅผ ์ ์ฒญํ์ต๋๋ค. ๋ฐ๋ค๋ฅด์ธ๋ฆฌ๋ฒ ๊ฐ์์์ 3์ผ์ ๋ณด๋ด๊ณ ์ ํฉ๋๋ค. ์ฟ ์๋ผ๋ฃธํธ๋ฅด์์ 4์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. 8์ผ๊ณผ 10์ผ ์ฌ์ด์ ์ฟ ์๋ผ๋ฃธํธ๋ฅด์์ ์งํ๋๋ ์น๊ตฌ์ ๊ฒฐํผ์์ ์ฐธ์ํ ์์ ์
๋๋ค. 3์ผ๊ฐ ๋๋ฆฌ๋ฅผ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. ๋๋ฆฌ๊ฐ ์ฒซ๋ฒ์งธ ์ฌํ์ง์์ผ๋ฉด ์ข๊ฒ ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ์ฟ ์๋ผ๋ฃธํธ๋ฅด์ ๋ง๋๋ผ, ์ฟ ์๋ผ๋ฃธํธ๋ฅด์ ์์นด๋ฅดํ, ๋ฐ๋ค๋ฅด์ธ๋ฆฌ๋ฒ ๊ฐ์์ ์ฟ ์๋ผ๋ฃธํธ๋ฅด, ๋ง๋๋ผ์ ๋ฐ๋ค๋ฅด์ธ๋ฆฌ๋ฒ ๊ฐ์, ๋ง๋๋ผ์ ์์นด๋ฅดํ, ๋๋ฆฌ์ ๋ฐ๋ค๋ฅด์ธ๋ฆฌ๋ฒ ๊ฐ์, ์์นด๋ฅดํ์ ๋๋ฆฌ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 16์ผ ๋์ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋๋ฆฌ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋๋ฆฌ์์ ์์นด๋ฅดํ๋ก ๋นํ.
3-7์ผ์ฐจ: 5์ผ๊ฐ ์์นด๋ฅดํ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ์์นด๋ฅดํ์์ ์ฟ ์๋ผ๋ฃธํธ๋ฅด๋ก ๋นํ.
7-10์ผ์ฐจ: 4์ผ๊ฐ ์ฟ ์๋ผ๋ฃธํธ๋ฅด ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ์ฟ ์๋ผ๋ฃธํธ๋ฅด์์ ๋ฐ๋ค๋ฅด์ธ๋ฆฌ๋ฒ ๊ฐ์์ผ๋ก ๋นํ.
10-12์ผ์ฐจ: 3์ผ๊ฐ ๋ฐ๋ค๋ฅด์ธ๋ฆฌ๋ฒ ๊ฐ์ ๋ฐฉ๋ฌธ.
12์ผ์ฐจ: ๋ฐ๋ค๋ฅด์ธ๋ฆฌ๋ฒ ๊ฐ์์์ ๋ง๋๋ผ๋ก ๋นํ.
12-16์ผ์ฐจ: 5์ผ๊ฐ ๋ง๋๋ผ ๋ฐฉ๋ฌธ.
|
You plan to visit 5 cities in Asia for a total of 16 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You will be in Jakarta for 5 days. You also want to spend 5 days in Manila. You've signed up for a tour of Manila between the 13th and 15th. You'd like to spend 3 days in Bandar Seri Begawan. You want to spend 4 days in Kuala Lumpur. You will be attending a friend's wedding in Kuala Lumpur between the 8th and 10th. You will be traveling to Dili for 3 days. You want Dili to be your first stop.
Here are the cities that have direct flights: Kuala Lumpur and Manila, Kuala Lumpur and Jakarta, Bandar Seri Begawan and Kuala Lumpur, Manila and Bandar Seri Begawan, Manila and Jakarta, Dili and Bandar Seri Begawan, Jakarta and Dili.
Plan a trip to visit five cities in 16 days with direct flights.
|
Days 1-3: Visit Dili for 3 days.
Day 3: Fly from Dili to Jakarta.
Days 3-7: Visit Jakarta for 5 days.
Day 7: Fly from Jakarta to Kuala Lumpur.
Days 7-10: Visit Kuala Lumpur for 4 days.
Day 10: Fly from Kuala Lumpur to Bandar Seri Begawan.
Days 10-12: Visit Bandar Seri Begawan for 3 days.
Day 12: Fly from Bandar Seri Begawan to Manila.
Days 12-16: Visit Manila for 5 days.
|
๋ณ์ ์ ์:
J: ์์นด๋ฅดํ, M: ๋ง๋๋ผ, B: ๋ฐ๋ค๋ฅด์ธ๋ฆฌ๋ฒ ๊ฐ์, K: ์ฟ ์๋ผ๋ฃธํธ๋ฅด, D: ๋๋ฆฌ
a_J: ์์นด๋ฅดํ ๋์ฐฉ์ผ, d_J: ์์นด๋ฅดํ ์ถ๋ฐ์ผ
a_M: ๋ง๋๋ผ ๋์ฐฉ์ผ, d_M: ๋ง๋๋ผ ์ถ๋ฐ์ผ
a_B: ๋ฐ๋ค๋ฅด์ธ๋ฆฌ๋ฒ ๊ฐ์ ๋์ฐฉ์ผ, d_B: ๋ฐ๋ค๋ฅด์ธ๋ฆฌ๋ฒ ๊ฐ์ ์ถ๋ฐ์ผ
a_K: ์ฟ ์๋ผ๋ฃธํธ๋ฅด ๋์ฐฉ์ผ, d_K: ์ฟ ์๋ผ๋ฃธํธ๋ฅด ์ถ๋ฐ์ผ
a_D: ๋๋ฆฌ ๋์ฐฉ์ผ, d_D: ๋๋ฆฌ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_J - a_J + 1 = 5
d_M - a_M + 1 = 5
d_B - a_B + 1 = 3
d_K - a_K + 1 = 4
d_D - a_D + 1 = 3
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_J, d_M, d_B, d_K, d_D) - min(a_J, a_M, a_B, a_K, a_D) + 1 = 16
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[13, 15] โฉ [a_M, d_M] โ โ
[8, 10] โฉ [a_K, d_K] โ โ
a_D = min(a_J, a_M, a_B, a_K, a_D)
์งํญํธ์ด ์๋ ๋์:
(K โ M), (K โ J), (B โ K), (M โ B), (M โ J), (D โ B), (J โ D)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋๋ฆฌ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋๋ฆฌ์์ ์์นด๋ฅดํ๋ก ๋นํ.
3-7์ผ์ฐจ: 5์ผ๊ฐ ์์นด๋ฅดํ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ์์นด๋ฅดํ์์ ์ฟ ์๋ผ๋ฃธํธ๋ฅด๋ก ๋นํ.
7-10์ผ์ฐจ: 4์ผ๊ฐ ์ฟ ์๋ผ๋ฃธํธ๋ฅด ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ์ฟ ์๋ผ๋ฃธํธ๋ฅด์์ ๋ฐ๋ค๋ฅด์ธ๋ฆฌ๋ฒ ๊ฐ์์ผ๋ก ๋นํ.
10-12์ผ์ฐจ: 3์ผ๊ฐ ๋ฐ๋ค๋ฅด์ธ๋ฆฌ๋ฒ ๊ฐ์ ๋ฐฉ๋ฌธ.
12์ผ์ฐจ: ๋ฐ๋ค๋ฅด์ธ๋ฆฌ๋ฒ ๊ฐ์์์ ๋ง๋๋ผ๋ก ๋นํ.
12-16์ผ์ฐจ: 5์ผ๊ฐ ๋ง๋๋ผ ๋ฐฉ๋ฌธ.
|
78
|
์์์
| 5
|
์ง์ ์์ฑ
|
์ด 15์ผ ๋์ ์์์ 5๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์ฟ ์๋ผ๋ฃธํธ๋ฅด์์ 7์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. ์ฌํ 8์ผ์ฐจ์ ์ฟ ์๋ผ๋ฃธํธ๋ฅด์์ ๊ฒฐํผ์์ ์ฐธ์ํ ์์ ์
๋๋ค. 4์ผ๊ฐ ํ๋
ธ์ด๋ฅผ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. 1-4์ผ์ ํ๋
ธ์ด์์ ๋ณด๋ผ ์์๋ฅผ ๋ฏธ๋ฆฌ ์์ฝํด๋์์ต๋๋ค. 3์ผ๊ฐ ๋ฐฉ์ฝ์ ๋ฐฉ๋ฌธํ ์์ ์
๋๋ค. ๋ฐ๋ค๋ฅด์ธ๋ฆฌ๋ฒ ๊ฐ์ ๋ํ 3์ผ์ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. ํ๋ํ์์ 2์ผ์ ์ฌํํ ๊ฒ์
๋๋ค. 6์ผ๊ณผ 7์ผ ์ฌ์ด์๋ ํ๋ํ์ ๋ค๋ฌ์ผ ํฉ๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ฐ๋ค๋ฅด์ธ๋ฆฌ๋ฒ ๊ฐ์๊ณผ ์ฟ ์๋ผ๋ฃธํธ๋ฅด, ํ๋ํ๊ณผ ๋ฐ๋ค๋ฅด์ธ๋ฆฌ๋ฒ ๊ฐ์, ํ๋ํ๊ณผ ์ฟ ์๋ผ๋ฃธํ๋ฅด, ํ๋ํ๊ณผ ๋ฐฉ์ฝ, ๋ฐฉ์ฝ์ ํ๋
ธ์ด, ํ๋
ธ์ด์ ์ฟ ์๋ผ๋ฃธํธ๋ฅด, ํ๋
ธ์ด์ ํ๋ํ, ํ๋
ธ์ด์ ๋ฐ๋ค๋ฅด์ธ๋ฆฌ๋ฒ ๊ฐ์.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 15์ผ ๋์ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ํ๋
ธ์ด ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ํ๋
ธ์ด์์ ๋ฐฉ์ฝ์ผ๋ก ๋นํ.
4-6์ผ์ฐจ: 3์ผ๊ฐ ๋ฐฉ์ฝ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋ฐฉ์ฝ์์ ํ๋ํ์ผ๋ก ๋นํ.
6-7์ผ์ฐจ: 2์ผ๊ฐ ํ๋ํ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ํ๋ํ์์ ์ฟ ์๋ผ๋ฃธํธ๋ฅด๋ก ๋นํ.
7-13์ผ์ฐจ: 7์ผ๊ฐ ์ฟ ์๋ผ๋ฃธํธ๋ฅด ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ์ฟ ์๋ผ๋ฃธํธ๋ฅด์์ ๋ฐ๋ค๋ฅด์ธ๋ฆฌ๋ฒ ๊ฐ์์ผ๋ก ๋นํ.
13-15์ผ์ฐจ: 3์ผ๊ฐ ๋ฐ๋ค๋ฅด์ธ๋ฆฌ๋ฒ ๊ฐ์ ๋ฐฉ๋ฌธ.
|
You plan to visit 5 cities in Asia for a total of 15 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to spend 7 days in Kuala Lumpur. You will be attending a wedding in Kuala Lumpur on day 8 of your trip. You'll be visiting Hanoi for 4 days. You've already booked accommodation for days 1-4 in Hanoi. You'll be visiting Bangkok for 3 days. You will also visit Bandar Seri Begawan for 3 days. You will spend 2 days in Phnom Penh. You need to stop in Phnom Penh between days 6 and 7.
Here are the cities that have direct flights: Bandar Seri Begawan and Kuala Lumpur, Phnom Penh and Bandar Seri Begawan, Phnom Penh and Kuala Lumpur, Phnom Penh and Bangkok, Bangkok and Hanoi, Hanoi and Kuala Lumpur, Hanoi and Phnom Penh, Hanoi and Bandar Seri Begawan.
Plan a trip to visit five cities in 15 days with direct flights.
|
Days 1-4: Visit Hanoi for 4 days.
Day 4: Fly from Hanoi to Bangkok.
Days 4-6: Visit Bangkok for 3 days.
Day 6: Fly from Bangkok to Phnom Penh.
Days 6-7: Visit Phnom Penh for 2 days.
Day 7: Fly from Phnom Penh to Kuala Lumpur.
Days 7-13: Visit Kuala Lumpur for 7 days.
Day 13: Fly from Kuala Lumpur to Bandar Seri Begawan.
Days 13-15: Visit Bandar Seri Begawan for 3 days.
|
๋ณ์ ์ ์:
K: ์ฟ ์๋ผ๋ฃธํธ๋ฅด, H: ํ๋
ธ์ด, B: ๋ฐฉ์ฝ, S: ๋ฐ๋ค๋ฅด์ธ๋ฆฌ๋ฒ ๊ฐ์, P: ํ๋ํ
a_K: ์ฟ ์๋ผ๋ฃธํธ๋ฅด ๋์ฐฉ์ผ, d_K: ์ฟ ์๋ผ๋ฃธํธ๋ฅด ์ถ๋ฐ์ผ
a_H: ํ๋
ธ์ด ๋์ฐฉ์ผ, d_H: ํ๋
ธ์ด ์ถ๋ฐ์ผ
a_B: ๋ฐฉ์ฝ ๋์ฐฉ์ผ, d_B: ๋ฐฉ์ฝ ์ถ๋ฐ์ผ
a_S: ๋ฐ๋ค๋ฅด์ธ๋ฆฌ๋ฒ ๊ฐ์ ๋์ฐฉ์ผ, d_S: ๋ฐ๋ค๋ฅด์ธ๋ฆฌ๋ฒ ๊ฐ์ ์ถ๋ฐ์ผ
a_P: ํ๋ํ ๋์ฐฉ์ผ, d_P: ํ๋ํ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_K - a_K + 1 = 7
d_H - a_H + 1 = 4
d_B - a_B + 1 = 3
d_S - a_S + 1 = 3
d_P - a_P + 1 = 2
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_K, d_H, d_B, d_S, d_P) - min(a_K, a_H, a_B, a_S, a_P) + 1 = 15
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
a_K โค 8 โค d_K
a_H = 1, d_H = 4
{6, 7} โฉ [a_P, d_P] โ โ
์งํญํธ์ด ์๋ ๋์:
(S โ K), (P โ S), (P โ K), (P โ B), (B โ H), (H โ K), (H โ P), (H โ S)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ํ๋
ธ์ด ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ํ๋
ธ์ด์์ ๋ฐฉ์ฝ์ผ๋ก ๋นํ.
4-6์ผ์ฐจ: 3์ผ๊ฐ ๋ฐฉ์ฝ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋ฐฉ์ฝ์์ ํ๋ํ์ผ๋ก ๋นํ.
6-7์ผ์ฐจ: 2์ผ๊ฐ ํ๋ํ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ํ๋ํ์์ ์ฟ ์๋ผ๋ฃธํธ๋ฅด๋ก ๋นํ.
7-13์ผ์ฐจ: 7์ผ๊ฐ ์ฟ ์๋ผ๋ฃธํธ๋ฅด ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ์ฟ ์๋ผ๋ฃธํธ๋ฅด์์ ๋ฐ๋ค๋ฅด์ธ๋ฆฌ๋ฒ ๊ฐ์์ผ๋ก ๋นํ.
13-15์ผ์ฐจ: 3์ผ๊ฐ ๋ฐ๋ค๋ฅด์ธ๋ฆฌ๋ฒ ๊ฐ์ ๋ฐฉ๋ฌธ.
|
79
|
์์์
| 5
|
์ง์ ์์ฑ
|
์ด 14์ผ ๋์ ์์์ 5๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ํ
ํค๋์์ 3์ผ๊ฐ ์ฌํ์ ํ๊ณ ์ถ์ต๋๋ค. ๋ค ๋ฒ์งธ ์ฌํ์ง๋ ํ
ํค๋์ด์์ผ๋ฉด ์ข๊ฒ ์ต๋๋ค. 5์ผ๊ฐ ์ด์ด๋ผ๋ง๋ฐ๋์์ ์๊ฐ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. ๋ฐ๊ทธ๋ค๋์์ 4์ผ์ ๋ณด๋ด๋ ค๊ณ ํฉ๋๋ค. 2์ผ๊ฐ ์ฝ๋กฌ๋ณด์์ ๋จธ๋ฌด๋ฅด๊ณ ์ถ์ต๋๋ค. 4์ผ๊ฐ ๋ญ๋ฐ์ด๋ฅผ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ญ๋ฐ์ด์ ์ฝ๋กฌ๋ณด, ์ด์ด๋ผ๋ง๋ฐ๋์ ๋ญ๋ฐ์ด, ํ
ํค๋๊ณผ ์ด์ด๋ผ๋ง๋ฐ๋, ๋ฐ๊ทธ๋ค๋์ ํ
ํค๋.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 14์ผ ๋์ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ์ฝ๋กฌ๋ณด ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ์ฝ๋กฌ๋ณด์์ ๋ญ๋ฐ์ด๋ก ๋นํ.
2-5์ผ์ฐจ: 4์ผ๊ฐ ๋ญ๋ฐ์ด ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋ญ๋ฐ์ด์์ ์ด์ด๋ผ๋ง๋ฐ๋๋ก ๋นํ.
5-9์ผ์ฐจ: 5์ผ๊ฐ ์ด์ด๋ผ๋ง๋ฐ๋ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ์ด์ด๋ผ๋ง๋ฐ๋์์ ํ
ํค๋์ผ๋ก ๋นํ.
9-11์ผ์ฐจ: 3์ผ๊ฐ ํ
ํค๋ ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ํ
ํค๋์์ ๋ฐ๊ทธ๋ค๋๋ก ๋นํ.
11-14์ผ์ฐจ: 4์ผ๊ฐ ๋ฐ๊ทธ๋ค๋ ๋ฐฉ๋ฌธ.
|
You plan to visit 5 cities in Asia for a total of 18 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to spend 3 days in Tehran. You'd like to spend 5 days in Islamabad. You'd like my fourth destination to be Tehran. You want to spend 4 days in Baghdad. You would like to spend 2 days in Colombo. You would like to visit Mumbai for 4 days.
Here are the cities that have direct flights: Mumbai and Colombo, Islamabad and Mumbai, Tehran and Islamabad, Baghdad and Tehran.
Plan a trip to visit five cities in 14 days with direct flights.
|
Day 1-2: Visit Colombo for 2 days.
Day 2: Fly from Colombo to Mumbai.
Days 2-5: Visit Mumbai for 4 days.
Day 5: Fly from Mumbai to Islamabad.
Days 5-9: Visit Islamabad for 5 days.
Day 9: Fly from Islamabad to Tehran.
Days 9-11: Visit Tehran for 3 days.
Day 11: Fly from Tehran to Baghdad.
Days 11-14: Visit Baghdad for 4 days.
|
๋ณ์ ์ ์:
T: ํ
ํค๋, I: ์ด์ฌ๋ผ๋ง๋ฐ๋, B: ๋ฐ๊ทธ๋ค๋, C: ์ฝ๋กฌ๋ณด, M: ๋ญ๋ฐ์ด
a_T: ํ
ํค๋ ๋์ฐฉ์ผ, d_T: ํ
ํค๋ ์ถ๋ฐ์ผ
a_I: ์ด์ฌ๋ผ๋ง๋ฐ๋ ๋์ฐฉ์ผ, d_I: ์ด์ฌ๋ผ๋ง๋ฐ๋ ์ถ๋ฐ์ผ
a_B: ๋ฐ๊ทธ๋ค๋ ๋์ฐฉ์ผ, d_B: ๋ฐ๊ทธ๋ค๋ ์ถ๋ฐ์ผ
a_C: ์ฝ๋กฌ๋ณด ๋์ฐฉ์ผ, d_C: ์ฝ๋กฌ๋ณด ์ถ๋ฐ์ผ
a_M: ๋ญ๋ฐ์ด ๋์ฐฉ์ผ, d_M: ๋ญ๋ฐ์ด ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_T - a_T + 1 = 3
d_I - a_I + 1 = 5
d_B - a_B + 1 = 4
d_C - a_C + 1 = 2
d_M - a_M + 1 = 4
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_T, d_I, d_B, d_C, d_M) - min(a_T, a_I, a_B, a_C, a_M) + 1 = 14
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
a_T = min(a_I, a_B, a_C, a_M) + 3
์งํญํธ์ด ์๋ ๋์:
(M โ C), (I โ M), (T โ I), (B โ T)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ์ฝ๋กฌ๋ณด ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ์ฝ๋กฌ๋ณด์์ ๋ญ๋ฐ์ด๋ก ๋นํ.
2-5์ผ์ฐจ: 4์ผ๊ฐ ๋ญ๋ฐ์ด ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋ญ๋ฐ์ด์์ ์ด์ด๋ผ๋ง๋ฐ๋๋ก ๋นํ.
5-9์ผ์ฐจ: 5์ผ๊ฐ ์ด์ด๋ผ๋ง๋ฐ๋ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ์ด์ด๋ผ๋ง๋ฐ๋์์ ํ
ํค๋์ผ๋ก ๋นํ.
9-11์ผ์ฐจ: 3์ผ๊ฐ ํ
ํค๋ ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ํ
ํค๋์์ ๋ฐ๊ทธ๋ค๋๋ก ๋นํ.
11-14์ผ์ฐจ: 4์ผ๊ฐ ๋ฐ๊ทธ๋ค๋ ๋ฐฉ๋ฌธ.
|
80
|
์์์
| 5
|
์ง์ ์์ฑ
|
์ด 17์ผ ๋์ ์์์ 5๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ๋ฒ ์ด๋ฃจํธ์์ 5์ผ์ ๋ณด๋ผ ๊ฒ์
๋๋ค. ํ
ํค๋์์ 3์ผ์ ๋ณด๋ผ ์์ ์
๋๋ค. 2์ผ๊ฐ ๋ค๋ง์ค์ปค์ค์ ๋ฐฉ๋ฌธํ๊ณ ์ถ์ต๋๋ค. ๋ค๋ง์ค์ปค์ค๋ 5-6์ผ ์ฌ์ด์ ๊ตฌ๊ฒฝํ๊ณ ์ถ์ต๋๋ค. 7์ผ๊ฐ ์ด์ฌ๋ผ๋ง๋ฐ๋์ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. 11์ผ๊ณผ 16์ผ ์ฌ์ด ์ด์ฌ๋ผ๋ง๋ฐ๋์์ ์น๊ตฌ์ ์์ผํํฐ์ ์ฐธ์ํ ์์ ์
๋๋ค. ๋ฐ๊ทธ๋ค๋์์ 4์ผ์ ์ฌํํ๊ณ ์ถ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ฒ ์ด๋ฃจํธ์ ํ
ํค๋, ๋ฒ ์ด๋ฃจํธ์ ๋ฐ๊ทธ๋ค๋, ๋ฒ ์ด๋ฃจํธ์ ๋ค๋ง์ค์ปค์ค, ํ
ํค๋๊ณผ ์ด์ฌ๋ผ๋ง๋ฐ๋, ๋ค๋ง์ค์ปค์ค์ ๋ฐ๊ทธ๋ค๋, ๋ค๋ง์ค์ปค์ค์ ์ด์ฌ๋ผ๋ง๋ฐ๋, ๋ฐ๊ทธ๋ค๋์ ์ด์ฌ๋ผ๋ง๋ฐ๋, ๋ฐ๊ทธ๋ค๋์ ํ
ํค๋.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 17์ผ ๋์ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ๋ฒ ์ด๋ฃจํธ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋ฒ ์ด๋ฃจํธ์์ ๋ค๋ง์ค์ปค์ค๋ก ๋นํ.
5-6์ผ์ฐจ: 2์ผ๊ฐ ๋ค๋ง์ค์ปค์ค ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋ค๋ง์ค์ปค์ค์์ ๋ฐ๊ทธ๋ค๋๋ก ๋นํ.
6-9์ผ์ฐจ: 4์ผ๊ฐ ๋ฐ๊ทธ๋ค๋ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ๋ฐ๊ทธ๋ค๋์์ ํ
ํค๋์ผ๋ก ๋นํ.
9-11์ผ์ฐจ: 3์ผ๊ฐ ํ
ํค๋ ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ํ
ํค๋์์ ์ด์ฌ๋ผ๋ง๋ฐ๋๋ก ๋นํ.
11-17์ผ์ฐจ: 7์ผ๊ฐ ์ด์ฌ๋ผ๋ง๋ฐ๋ ๋ฐฉ๋ฌธ.
|
You plan to visit 5 cities in Asia for a total of 17 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'll spend 5 days in Beirut. You'll spend 3 days in Tehran. You'd like to visit Damascus for 2 days. You'd like to visit Damascus between days 5 and 6. You'll be in Islamabad for 7 days. You'll be in Islamabad between days 11 and 16 to attend a friend's birthday party. You want to spend 4 days in Baghdad.
Here are the cities that have direct flights: Beirut and Tehran, Beirut and Baghdad, Beirut and Damascus, Tehran and Islamabad, Damascus and Baghdad, Damascus and Islamabad, Baghdad and Islamabad, Baghdad and Tehran.
Plan a trip to visit five cities in 17 days with direct flights.
|
Days 1-5: Visit Beirut for 5 days.
Day 5: Fly from Beirut to Damascus.
Days 5-6: Visit Damascus for 2 days.
Day 6: Fly from Damascus to Baghdad.
Days 6-9: Visit Baghdad for 4 days.
Day 9: Fly from Baghdad to Tehran.
Days 9-11: Visit Tehran for 3 days.
Day 11: Fly from Tehran to Islamabad.
Days 11-17: Visit Islamabad for 7 days.
|
๋ณ์ ์ ์:
B: ๋ฒ ์ด๋ฃจํธ, T: ํ
ํค๋, D: ๋ค๋ง์ค์ปค์ค, I: ์ด์ฌ๋ผ๋ง๋ฐ๋, G: ๋ฐ๊ทธ๋ค๋
a_B: ๋ฒ ์ด๋ฃจํธ ๋์ฐฉ์ผ, d_B: ๋ฒ ์ด๋ฃจํธ ์ถ๋ฐ์ผ
a_T: ํ
ํค๋ ๋์ฐฉ์ผ, d_T: ํ
ํค๋ ์ถ๋ฐ์ผ
a_D: ๋ค๋ง์ค์ปค์ค ๋์ฐฉ์ผ, d_D: ๋ค๋ง์ค์ปค์ค ์ถ๋ฐ์ผ
a_I: ์ด์ฌ๋ผ๋ง๋ฐ๋ ๋์ฐฉ์ผ, d_I: ์ด์ฌ๋ผ๋ง๋ฐ๋ ์ถ๋ฐ์ผ
a_G: ๋ฐ๊ทธ๋ค๋ ๋์ฐฉ์ผ, d_G: ๋ฐ๊ทธ๋ค๋ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_B - a_B + 1 = 5
d_T - a_T + 1 = 3
d_D - a_D + 1 = 2
d_I - a_I + 1 = 7
d_G - a_G + 1 = 4
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_B, d_T, d_D, d_I, d_G) - min(a_B, a_T, a_D, a_I, a_G) + 1 = 17
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[5, 6] โฉ [a_D, d_D] โ โ
[11, 16] โฉ [a_I, d_I] โ โ
์งํญํธ์ด ์๋ ๋์:
(B โ T), (B โ G), (B โ D), (T โ I), (D โ G), (D โ I), (G โ I), (G โ T)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ๋ฒ ์ด๋ฃจํธ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋ฒ ์ด๋ฃจํธ์์ ๋ค๋ง์ค์ปค์ค๋ก ๋นํ.
5-6์ผ์ฐจ: 2์ผ๊ฐ ๋ค๋ง์ค์ปค์ค ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋ค๋ง์ค์ปค์ค์์ ๋ฐ๊ทธ๋ค๋๋ก ๋นํ.
6-9์ผ์ฐจ: 4์ผ๊ฐ ๋ฐ๊ทธ๋ค๋ ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ๋ฐ๊ทธ๋ค๋์์ ํ
ํค๋์ผ๋ก ๋นํ.
9-11์ผ์ฐจ: 3์ผ๊ฐ ํ
ํค๋ ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ํ
ํค๋์์ ์ด์ฌ๋ผ๋ง๋ฐ๋๋ก ๋นํ.
11-17์ผ์ฐจ: 7์ผ๊ฐ ์ด์ฌ๋ผ๋ง๋ฐ๋ ๋ฐฉ๋ฌธ.
|
81
|
์์์
| 6
|
์ง์ ์์ฑ
|
์ด 20์ผ ๋์ ์์์ 6๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. 3์ผ ๋์ ๋ฆฌ์ผ๋์์ ์ฌํ์ ํ๊ณ ์ถ์ต๋๋ค. ์ฌ๋์ ๋ฌด์ค์นดํธ์์ ๊ฐ๊ฐ 4์ผ์ ๋ณด๋ด๊ณ ์ ํฉ๋๋ค. ์ฌ๋์์ 2์ผ๊ณผ 3์ผ ์ฌ์ด์ ์ฌ์
ํํธ๋๋ฅผ ๋ง๋๊ธฐ๋ก ํ์ต๋๋ค. ์๋ฃจ์ด๋ ์์ 2์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. ์๋ฃจ์ด๋ ์ด ๋ง์ง๋ง ์ฌ์ ์ง์์ผ๋ฉด ์ข๊ฒ ์ต๋๋ค. 7์ผ ๊ฐ์ ์๋ถ๋ค๋น์ ์์ผ๋ ค๊ณ ํฉ๋๋ค. 7์ผ๋ถํฐ 13์ผ ์ฌ์ด์ ์๋ถ๋ค๋น์ ์ฌ๋ ์น์ฒ์ง์ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. 5์ผ๊ฐ ์๋ง์ ๋ฐฉ๋ฌธํ ์์ ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ์ฌ๋์ ์๋ถ๋ค๋น, ์ฌ๋์ ์๋ง, ๋ฌด์ค์นดํธ์ ์ฌ๋, ์๋ถ๋ค๋น์ ๋ฌด์ค์นดํธ, ์๋ถ๋ค๋น์ ์๋ฃจ์ด๋ , ๋ฆฌ์ผ๋์ ์๋ถ๋ค๋น, ๋ฆฌ์ผ๋์ ์๋ฃจ์ด๋ , ๋ฆฌ์ผ๋์ ์๋ง, ์๋ฃจ์ด๋ ๊ณผ ์๋ง.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 20์ผ ๋์ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ์ฌ๋ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ์ฌ๋์์ ๋ฌด์ค์นดํธ๋ก ๋นํ.
4-7์ผ์ฐจ: 4์ผ๊ฐ ๋ฌด์ค์นดํธ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ๋ฌด์ค์นดํธ์์ ์๋ถ๋ค๋น๋ก ๋นํ.
7-13์ผ์ฐจ: 7์ผ๊ฐ ์๋ถ๋ค๋น ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ์๋ถ๋ค๋น์์ ๋ฆฌ์ผ๋๋ก ๋นํ.
13-15์ผ์ฐจ: 3์ผ๊ฐ ๋ฆฌ์ผ๋ ๋ฐฉ๋ฌธ.
15์ผ์ฐจ: ๋ฆฌ์ผ๋์์ ์๋ง์ผ๋ก ๋นํ.
15-19์ผ์ฐจ: 5์ผ๊ฐ ์๋ง ๋ฐฉ๋ฌธ.
19์ผ์ฐจ: ์๋ง์์ ์๋ฃจ์ด๋ ์ผ๋ก ๋นํ.
19-20์ผ์ฐจ: 2์ผ๊ฐ ์๋ฃจ์ด๋ ๋ฐฉ๋ฌธ.
|
You plan to visit 6 cities in Asia for a total of 20 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to spend 3 days in Riyadh. You want to spend 4 days in Sanaa and Muscat. You want to meet with a business partner between days 2 and 3 in Sanaa. You want to spend 2 days in Jerusalem. You want Jerusalem to be the last stop on your trip. You want to be in Abu Dhabi for 7 days. You want to visit a relative in Abu Dhabi between days 7 and 13. You want to visit Amman for 5 days.
Here are the cities that have direct flights: Sanaa and Abu Dhabi, Sanaa and Amman, Muscat and Sanaa, Abu Dhabi and Muscat, Abu Dhabi and Jerusalem, Riyadh and Abu Dhabi, Riyadh and Jerusalem, Riyadh and Amman, Jerusalem and Amman.
Plan a trip to visit six cities in 20 days with direct flights.
|
Days 1-4: Visit Sanaa for 4 days.
Day 4: Fly from Sanaa to Muscat.
Days 4-7: Visit Muscat for 4 days.
Day 7: Fly from Muscat to Abu Dhabi.
Days 7-13: Visit Abu Dhabi for 7 days.
Day 13: Fly from Abu Dhabi to Riyadh.
Days 13-15: Visit Riyadh for 3 days.
Day 15: Fly from Riyadh to Amman.
Days 15-19: Visit Amman for 5 days.
Day 19: Fly from Amman to Jerusalem.
Days 19-20: Visit Jerusalem for 2 days.
|
๋ณ์ ์ ์:
R: ๋ฆฌ์ผ๋, S: ์ฌ๋, M: ๋ฌด์ค์นดํธ, J: ์๋ฃจ์ด๋ , A: ์๋ถ๋ค๋น, Am: ์๋ง
a_R: ๋ฆฌ์ผ๋ ๋์ฐฉ์ผ, d_R: ๋ฆฌ์ผ๋ ์ถ๋ฐ์ผ
a_S: ์ฌ๋ ๋์ฐฉ์ผ, d_S: ์ฌ๋ ์ถ๋ฐ์ผ
a_M: ๋ฌด์ค์นดํธ ๋์ฐฉ์ผ, d_M: ๋ฌด์ค์นดํธ ์ถ๋ฐ์ผ
a_J: ์๋ฃจ์ด๋ ๋์ฐฉ์ผ, d_J: ์๋ฃจ์ด๋ ์ถ๋ฐ์ผ
a_A: ์๋ถ๋ค๋น ๋์ฐฉ์ผ, d_A: ์๋ถ๋ค๋น ์ถ๋ฐ์ผ
a_Am: ์๋ง ๋์ฐฉ์ผ, d_Am: ์๋ง ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_R - a_R + 1 = 3
d_S - a_S + 1 = 4
d_M - a_M + 1 = 4
d_J - a_J + 1 = 2
d_A - a_A + 1 = 7
d_Am - a_Am + 1 = 5
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_R, d_S, d_M, d_J, d_A, d_Am) - min(a_R, a_S, a_M, a_J, a_A, a_Am) + 1 = 20
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[2, 3] โฉ [a_S, d_S] โ โ
[7, 13] โฉ [a_A, d_A] โ โ
d_J = 20
์งํญํธ์ด ์๋ ๋์:
(S โ A), (S โ Am), (M โ S), (A โ M), (A โ J), (R โ A), (R โ J), (R โ Am), (J โ Am)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ์ฌ๋ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ์ฌ๋์์ ๋ฌด์ค์นดํธ๋ก ๋นํ.
4-7์ผ์ฐจ: 4์ผ๊ฐ ๋ฌด์ค์นดํธ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ๋ฌด์ค์นดํธ์์ ์๋ถ๋ค๋น๋ก ๋นํ.
7-13์ผ์ฐจ: 7์ผ๊ฐ ์๋ถ๋ค๋น ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ์๋ถ๋ค๋น์์ ๋ฆฌ์ผ๋๋ก ๋นํ.
13-15์ผ์ฐจ: 3์ผ๊ฐ ๋ฆฌ์ผ๋ ๋ฐฉ๋ฌธ.
15์ผ์ฐจ: ๋ฆฌ์ผ๋์์ ์๋ง์ผ๋ก ๋นํ.
15-19์ผ์ฐจ: 5์ผ๊ฐ ์๋ง ๋ฐฉ๋ฌธ.
19์ผ์ฐจ: ์๋ง์์ ์๋ฃจ์ด๋ ์ผ๋ก ๋นํ.
19-20์ผ์ฐจ: 2์ผ๊ฐ ์๋ฃจ์ด๋ ๋ฐฉ๋ฌธ.
|
82
|
์์์
| 6
|
์ง์ ์์ฑ
|
์ด 19์ผ ๋์ ์์์ 6๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์์คํํ์์ 4์ผ์ ๋ณด๋ผ ๊ฒ์
๋๋ค. 4์ผ๊ฐ ๋ฐ๊ทธ๋ค๋๋ฅผ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. ๋ฐ๊ทธ๋ค๋์์ 13์ผ๊ณผ 16์ผ ์ฌ์ด์ ์ง๋ผ ์์ด๋น์ค๋น๋ฅผ ๋ฏธ๋ฆฌ ์์ฝํด๋์์ต๋๋ค. ์๋ฃจ์ด๋ ์์ 4์ผ ๋์ ์ฌํ์ ํ ๊ฒ์
๋๋ค. 3์ผ๊ณผ 6์ผ ์ฌ์ด์๋ ์๋ฃจ์ด๋ ์์ ์ฑ์ง์๋ก๋ฅผ ํ๊ณ ์ถ์ต๋๋ค. 6์ผ ๋์ ๋ฒ ์ด๋ฃจํธ๋ฅผ ๋ฐฉ๋ฌธํ ์์ ์
๋๋ค. 7์ผ๊ณผ 10์ผ ์ฌ์ด์๋ ๋ฒ ์ด๋ฃจํธ์ ์์ด์ผ ํฉ๋๋ค. ์๋ง์์ 3์ผ์ ๋ณด๋ด๊ณ ์ ํฉ๋๋ค. ๋ค๋ง์ค์ปค์ค์์ 3์ผ์ ๋ณด๋ผ ๊ฒ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ค๋ง์ค์ปคํธ์ ๋ฐ๊ทธ๋ค๋, ์์คํํ๊ณผ ๋ฐ๊ทธ๋ค๋, ๋ฒ ์ด๋ฃจํธ์ ๋ฐ๊ทธ๋ค๋, ๋ฒ ์ด๋ฃจํธ์ ์๋ฃจ์ด๋ , ๋ฒ ์ด๋ฃจํธ์ ์์คํํ, ๋ค๋ง์ค์ปค์ค์ ๋ฒ ์ด๋ฃจํธ, ์๋ฃจ์ด๋ ๊ณผ ์๋ง, ์๋ฃจ์ด๋ ๊ณผ ๋ค๋ง์ค์ปค์ค, ์๋ฃจ์ด๋ ๊ณผ ์์คํํ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 19์ผ ๋์ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ์๋ง ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ์๋ง์์ ์๋ฃจ์ด๋ ์ผ๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ์๋ฃจ์ด๋ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์๋ฃจ์ด๋ ์์ ๋ฒ ์ด๋ฃจํธ๋ก ๋นํ.
6-11์ผ์ฐจ: 6์ผ๊ฐ ๋ฒ ์ด๋ฃจํธ ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ๋ฒ ์ด๋ฃจํธ์์ ๋ค๋ง์ค์ปค์ค๋ก ๋นํ.
11-13์ผ์ฐจ: 3์ผ๊ฐ ๋ค๋ง์ค์ปค์ค ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ๋ค๋ง์ค์ปค์ค์์ ๋ฐ๊ทธ๋ค๋๋ก ๋นํ.
13-16์ผ์ฐจ: 4์ผ๊ฐ ๋ฐ๊ทธ๋ค๋ ๋ฐฉ๋ฌธ.
16์ผ์ฐจ: ๋ฐ๊ทธ๋ค๋์์ ์์คํํ์ผ๋ก ๋นํ.
16-19์ผ์ฐจ: 4์ผ๊ฐ ์์คํํ ๋ฐฉ๋ฌธ.
|
You plan to visit 6 cities in Asia for a total of 19 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'll be spending 4 days in Asfahan. You'll be visiting Baghdad for 4 days. You've already booked an Airbnb in Baghdad for between the 13th and 16th. You'll be in Jerusalem for 4 days. You would like to go on a pilgrimage in Jerusalem between the 3rd and the 6th. You'll be visiting Beirut for 6 days. Between days 7 and 10, You need to be in Beirut. You want to spend 3 days in Amman. You will spend 3 days in Damascus.
Here are the cities that have direct flights: Damascus and Baghdad, Asfahan and Baghdad, Beirut and Baghdad, Beirut and Jerusalem, Beirut and Asfahan, Damascus and Beirut, Jerusalem and Amman, Jerusalem and Damascus, Jerusalem and Asfahan.
Plan a trip to visit six cities in 19 days with direct flights.
|
Days 1-3: Visit Amman for 3 days.
Day 3: Fly from Amman to Jerusalem.
Days 3-6: Visit Jerusalem for 4 days.
Day 6: Fly from Jerusalem to Beirut.
Days 6-11: Visit Beirut for 6 days.
Day 11: Fly from Beirut to Damascus.
Days 11-13: Visit Damascus for 3 days.
Day 13: Fly from Damascus to Baghdad.
Days 13-16: Visit Baghdad for 4 days.
Day 16: Fly from Baghdad to Asfahan.
Days 16-19: Visit Asfahan for 4 days.
|
๋ณ์ ์ ์:
I: ์์คํํ, B: ๋ฐ๊ทธ๋ค๋, J: ์๋ฃจ์ด๋ , L: ๋ฒ ์ด๋ฃจํธ, A: ์๋ง, D: ๋ค๋ง์ค์ปค์ค
a_I: ์์คํํ ๋์ฐฉ์ผ, d_I: ์์คํํ ์ถ๋ฐ์ผ
a_B: ๋ฐ๊ทธ๋ค๋ ๋์ฐฉ์ผ, d_B: ๋ฐ๊ทธ๋ค๋ ์ถ๋ฐ์ผ
a_J: ์๋ฃจ์ด๋ ๋์ฐฉ์ผ, d_J: ์๋ฃจ์ด๋ ์ถ๋ฐ์ผ
a_L: ๋ฒ ์ด๋ฃจํธ ๋์ฐฉ์ผ, d_L: ๋ฒ ์ด๋ฃจํธ ์ถ๋ฐ์ผ
a_A: ์๋ง ๋์ฐฉ์ผ, d_A: ์๋ง ์ถ๋ฐ์ผ
a_D: ๋ค๋ง์ค์ปค์ค ๋์ฐฉ์ผ, d_D: ๋ค๋ง์ค์ปค์ค ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_I - a_I + 1 = 4
d_B - a_B + 1 = 4
d_J - a_J + 1 = 4
d_L - a_L + 1 = 6
d_A - a_A + 1 = 3
d_D - a_D + 1 = 3
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_I, d_B, d_J, d_L, d_A, d_D) - min(a_I, a_B, a_J, a_L, a_A, a_D) + 1 = 19
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[13, 16] โฉ [a_B, d_B] โ โ
[3, 6] โฉ [a_J, d_J] โ โ
[7, 10] โฉ [a_L, d_L] โ โ
์งํญํธ์ด ์๋ ๋์:
(D โ B), (I โ B), (L โ B), (L โ J), (L โ I), (D โ L), (J โ A), (J โ D), (J โ I)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ์๋ง ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ์๋ง์์ ์๋ฃจ์ด๋ ์ผ๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ์๋ฃจ์ด๋ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์๋ฃจ์ด๋ ์์ ๋ฒ ์ด๋ฃจํธ๋ก ๋นํ.
6-11์ผ์ฐจ: 6์ผ๊ฐ ๋ฒ ์ด๋ฃจํธ ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ๋ฒ ์ด๋ฃจํธ์์ ๋ค๋ง์ค์ปค์ค๋ก ๋นํ.
11-13์ผ์ฐจ: 3์ผ๊ฐ ๋ค๋ง์ค์ปค์ค ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ๋ค๋ง์ค์ปค์ค์์ ๋ฐ๊ทธ๋ค๋๋ก ๋นํ.
13-16์ผ์ฐจ: 4์ผ๊ฐ ๋ฐ๊ทธ๋ค๋ ๋ฐฉ๋ฌธ.
16์ผ์ฐจ: ๋ฐ๊ทธ๋ค๋์์ ์์คํํ์ผ๋ก ๋นํ.
16-19์ผ์ฐจ: 4์ผ๊ฐ ์์คํํ ๋ฐฉ๋ฌธ.
|
83
|
์์์
| 6
|
์ง์ ์์ฑ
|
์ด 22์ผ ๋์ ์์์ 6๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. 3์ผ๊ฐ ํ์์์ ๋จธ๋ฌผ๊ณ ์ ํฉ๋๋ค. ์ํธํํ
๋ฅด๋ถ๋ฅดํฌ์์ 6์ผ๊ฐ ์๊ณ ์ ํฉ๋๋ค. ์ค์ฌ์นด์์ 3์ผ์ ๋ณด๋ด๋ ค ํฉ๋๋ค. 4์ผ ๋์ ์ํ์ด์์ ์ฌํ์ ์ฆ๊ธฐ๋ ค ํฉ๋๋ค.์ธ์ฒ์์ 6์ผ์ ๋จธ๋ฌผ ๊ฒ์
๋๋ค. 17์ผ๊ณผ 18์ผ ์ฌ์ด์ ์ธ์ฒ์์ ์ด๋ฆฌ๋ ํ์คํฐ๋ฒ์ ์ฐธ๊ฐํ๊ณ ์ถ์ต๋๋ค. 5์ผ๊ฐ ์ธ๋๋ฐํ ๋ฅด๋ฅผ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ์ธ๋๋ฐํ ๋ฅด์ ์ํธํํ
๋ถ๋ฅดํฌ, ํ์๊ณผ ์ธ์ฒ, ์ํ์ด์ ํ์, ์ธ๋๋ฐํ ๋ฅด์ ์ํ์ด, ์ธ์ฒ๊ณผ ์ค์ฌ์นด.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 22์ผ ๋์ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-6์ผ์ฐจ: 6์ผ๊ฐ ์ํธํํ
๋ฅด๋ถ๋ฅดํฌ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์ํธํํ
๋ฅด๋ถ๋ฅดํฌ์์ ์ธ๋๋ฐํ ๋ฅด๋ก ๋นํ.
6-10์ผ์ฐจ: 5์ผ๊ฐ ์ธ๋๋ฐํ ๋ฅด ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ์ธ๋๋ฐํ ๋ฅด์์ ์ํ์ด๋ก ๋นํ.
10-13์ผ์ฐจ: 4์ผ๊ฐ ์ํ์ด ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ์ํ์ด์์ ํ์์ผ๋ก ๋นํ.
13-15์ผ์ฐจ: 3์ผ๊ฐ ํ์ ๋ฐฉ๋ฌธ.
15์ผ์ฐจ: ํ์์์ ์ธ์ฒ์ผ๋ก ๋นํ.
15-20์ผ์ฐจ: 6์ผ๊ฐ ์ธ์ฒ ๋ฐฉ๋ฌธ.
20์ผ์ฐจ: ์ธ์ฒ์์ ์ค์ฌ์นด๋ก ๋นํ.
20-22์ผ์ฐจ: 3์ผ๊ฐ ์ค์ฌ์นด ๋ฐฉ๋ฌธ.
|
You plan to visit 6 cities in Asia for a total of 22 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to spend 3 days in Pyongyang. You want to spend 6 days in St. Petersburg. You want to spend 3 days in Osaka.You want to spend 4 days in Shanghai.You want to spend 6 days in Incheon.You want to attend a festival in Incheon between the 17th and 18th.You want to visit Ulaanbaatar for 5 days.
Here are the cities that have direct flights: Ulaanbaatar and St. Petersburg, Pyongyang and Incheon, Shanghai and Pyongyang, Ulaanbaatar and Shanghai, Incheon and Osaka.
Plan your trip to visit six cities in 22 days with direct flights.
|
Days 1-6: Visit St. Petersburg for 6 days.
Day 6: Fly from St. Petersburg to Ulaanbaatar.
Days 6-10: Visit Ulaanbaatar for 5 days.
Day 10: Fly from Ulaanbaatar to Shanghai.
Days 10-13: Visit Shanghai for 4 days.
Day 13: Fly from Shanghai to Pyongyang.
Days 13-15: Visit Pyongyang for 3 days.
Day 15: Fly from Pyongyang to Incheon.
Days 15-20: Visit Incheon for 6 days.
Day 20: Fly from Incheon to Osaka.
Days 20-22: Visit Osaka for 3 days.
|
๋ณ์ ์ ์:
P: ํ์, S: ์ํธํํ
๋ฅด๋ถ๋ฅดํฌ, O: ์ค์ฌ์นด, H: ์ํ์ด, I: ์ธ์ฒ, U: ์ธ๋๋ฐํ ๋ฅด
a_P: ํ์ ๋์ฐฉ์ผ, d_P: ํ์ ์ถ๋ฐ์ผ
a_S: ์ํธํํ
๋ฅด๋ถ๋ฅดํฌ ๋์ฐฉ์ผ, d_S: ์ํธํํ
๋ฅด๋ถ๋ฅดํฌ ์ถ๋ฐ์ผ
a_O: ์ค์ฌ์นด ๋์ฐฉ์ผ, d_O: ์ค์ฌ์นด ์ถ๋ฐ์ผ
a_H: ์ํ์ด ๋์ฐฉ์ผ, d_H: ์ํ์ด ์ถ๋ฐ์ผ
a_I: ์ธ์ฒ ๋์ฐฉ์ผ, d_I: ์ธ์ฒ ์ถ๋ฐ์ผ
a_U: ์ธ๋๋ฐํ ๋ฅด ๋์ฐฉ์ผ, d_U: ์ธ๋๋ฐํ ๋ฅด ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_P - a_P + 1 = 3
d_S - a_S + 1 = 6
d_O - a_O + 1 = 3
d_H - a_H + 1 = 4
d_I - a_I + 1 = 6
d_U - a_U + 1 = 5
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_P, d_S, d_O, d_H, d_I, d_U) - min(a_P, a_S, a_O, a_H, a_I, a_U) + 1 = 22
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[17, 18] โฉ [a_I, d_I] โ โ
์งํญํธ์ด ์๋ ๋์:
(U โ S), (P โ I), (H โ P), (U โ H), (I โ O)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-6์ผ์ฐจ: 6์ผ๊ฐ ์ํธํํ
๋ฅด๋ถ๋ฅดํฌ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์ํธํํ
๋ฅด๋ถ๋ฅดํฌ์์ ์ธ๋๋ฐํ ๋ฅด๋ก ๋นํ.
6-10์ผ์ฐจ: 5์ผ๊ฐ ์ธ๋๋ฐํ ๋ฅด ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ์ธ๋๋ฐํ ๋ฅด์์ ์ํ์ด๋ก ๋นํ.
10-13์ผ์ฐจ: 4์ผ๊ฐ ์ํ์ด ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ์ํ์ด์์ ํ์์ผ๋ก ๋นํ.
13-15์ผ์ฐจ: 3์ผ๊ฐ ํ์ ๋ฐฉ๋ฌธ.
15์ผ์ฐจ: ํ์์์ ์ธ์ฒ์ผ๋ก ๋นํ.
15-20์ผ์ฐจ: 6์ผ๊ฐ ์ธ์ฒ ๋ฐฉ๋ฌธ.
20์ผ์ฐจ: ์ธ์ฒ์์ ์ค์ฌ์นด๋ก ๋นํ.
20-22์ผ์ฐจ: 3์ผ๊ฐ ์ค์ฌ์นด ๋ฐฉ๋ฌธ.
|
84
|
์์์
| 6
|
์ง์ ์์ฑ
|
์ด 23์ผ ๋์ ์์์ 6๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์ฟํฌ๋ก๋ฅผ 4์ผ ๋์ ๋ฐฉ๋ฌธํ ์์ ์
๋๋ค. 3์ผ๊ฐ ๋ง๋๋ผ์์ ๋จธ๋ฌผ ๊ฒ์
๋๋ค. ๋ง๋๋ผ์ ์ ๋ช
ํ ๋ ์คํ ๋์ ์ฌํ 2์ผ์ฐจ์ ์์ฝํด๋์์ต๋๋ค. ๋ฏ๋ฆ์์ 6์ผ์ ๋ณด๋ด๊ณ ์ ํฉ๋๋ค. 6์ผ๊ฐ ํ์ด๋ฒ ์ด์์ ๋จธ๋ฌผ ์์ ์
๋๋ค. ๊ด์ฃผ๋ฅผ 4์ผ ๋์ ์ฌํํ๊ณ ์ถ์ต๋๋ค. ์ฌํ 12์ผ์ฐจ์ ๊ด์ฃผ์์ ์น๊ตฌ ์๋ค์ ๋์์น๋ฅผ ์ฐธ์ํ๊ธฐ๋ก ํ์ต๋๋ค. 5์ผ๊ฐ ์ฐํ์์ ์ง๋ผ ๊ฒ์
๋๋ค. ์ฐํ์์ 14-16์ผ ์ฌ์ด์ ๋น์ฆ๋์ค ๋ฏธํ
์ด ์์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ง๋๋ผ์ ํ์ด๋ฒ ์ด, ๋ง๋๋ผ์ ๊ด์ฃผ, ๋ฏ๋ฆ๊ณผ ์ฐํ, ๋ฏ๋ฆ๊ณผ ํ์ด๋ฒ ์ด, ์ฟํฌ๋ก์ ํ์ด๋ฒ ์ด, ์ฟํฌ๋ก์ ์ฐํ, ์ฐํ๊ณผ ๋ง๋๋ผ, ์ฐํ๊ณผ ๊ด์ฃผ, ํ์ด๋ฒ ์ด์ ๊ด์ฃผ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 23์ผ ๋์ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋ง๋๋ผ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋ง๋๋ผ์์ ํ์ด๋ฒ ์ด๋ก ๋นํ.
3-8์ผ์ฐจ: 6์ผ๊ฐ ํ์ด๋ฒ ์ด ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ํ์ด๋ฒ ์ด์์ ์ฟํฌ๋ก๋ก ๋นํ.
8-11์ผ์ฐจ: 4์ผ๊ฐ ์ฟํฌ๋ก ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ์ฟํฌ๋ก์์ ๊ด์ฃผ๋ก ๋นํ.
11-14์ผ์ฐจ: 4์ผ๊ฐ ๊ด์ฃผ ๋ฐฉ๋ฌธ.
14์ผ์ฐจ: ๊ด์ฃผ์์ ์ฐํ์ผ๋ก ๋นํ.
14-18์ผ์ฐจ: 5์ผ๊ฐ ์ฐํ ๋ฐฉ๋ฌธ.
18์ผ์ฐจ: ์ฐํ์์ ๋ฏ๋ฆ์ผ๋ก ๋นํ.
18-23์ผ์ฐจ: 6์ผ๊ฐ ๋ฏ๋ฆ ๋ฐฉ๋ฌธ.
|
You plan to visit 6 cities in Asia for a total of 23 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'll be visiting Sapporo for 4 days. You'll spend three days in Manila. You have reservations at a famous restaurant in Manila for day 2 of your trip. You want to spend 6 days in Moron. You will be staying in Taipei for 6 days. You want to travel to Gwangju for 4 days. You're attending a friend's son's birthday party in Gwangju on day 12 of your trip. You'll be in Wuhan for 5 days. You have a business meeting in Wuhan between days 14-16.
Here are the cities that have direct flights: Manila and Taipei, Manila and Gwangju, Moron and Wuhan, Moron and Taipei, Sapporo and Taipei, Sapporo and Wuhan, Wuhan and Manila, Wuhan and Gwangju, Taipei and Gwangju.
Plan a trip to visit six cities in 23 days with direct flights.
|
Days 1-3: Visit Manila for 3 days.
Day 3: Fly from Manila to Taipei.
Days 3-8: Visit Taipei for 6 days.
Day 8: Fly from Taipei to Sapporo.
Days 8-11: Visit Sapporo for 4 days.
Day 11: Fly from Sapporo to Gwangju.
Days 11-14: Visit Gwangju for 4 days.
Day 14: Fly from Gwangju to Wuhan.
Days 14-18: Visit Wuhan for 5 days.
Day 18: Fly from Wuhan to Moron.
Days 18-23: Visit Moron for 6 days.
|
๋ณ์ ์ ์:
S: ์ฟํฌ๋ก, M: ๋ง๋๋ผ, R: ๋ฏ๋ฆ, T: ํ์ด๋ฒ ์ด, G: ๊ด์ฃผ, W: ์ฐํ
a_S: ์ฟํฌ๋ก ๋์ฐฉ์ผ, d_S: ์ฟํฌ๋ก ์ถ๋ฐ์ผ
a_M: ๋ง๋๋ผ ๋์ฐฉ์ผ, d_M: ๋ง๋๋ผ ์ถ๋ฐ์ผ
a_R: ๋ฏ๋ฆ ๋์ฐฉ์ผ, d_R: ๋ฏ๋ฆ ์ถ๋ฐ์ผ
a_T: ํ์ด๋ฒ ์ด ๋์ฐฉ์ผ, d_T: ํ์ด๋ฒ ์ด ์ถ๋ฐ์ผ
a_G: ๊ด์ฃผ ๋์ฐฉ์ผ, d_G: ๊ด์ฃผ ์ถ๋ฐ์ผ
a_W: ์ฐํ ๋์ฐฉ์ผ, d_W: ์ฐํ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_S - a_S + 1 = 4
d_M - a_M + 1 = 3
d_R - a_R + 1 = 6
d_T - a_T + 1 = 6
d_G - a_G + 1 = 4
d_W - a_W + 1 = 5
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_S, d_M, d_R, d_T, d_G, d_W) - min(a_S, a_M, a_R, a_T, a_G, a_W) + 1 = 23
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
a_M โค 2 โค d_M
a_G โค 12 โค d_G
[14, 16] โฉ [a_W, d_W] โ โ
์งํญํธ์ด ์๋ ๋์:
(M โ T), (M โ G), (R โ W), (R โ T), (S โ T), (S โ W), (W โ M), (W โ G), (T โ G)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋ง๋๋ผ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋ง๋๋ผ์์ ํ์ด๋ฒ ์ด๋ก ๋นํ.
3-8์ผ์ฐจ: 6์ผ๊ฐ ํ์ด๋ฒ ์ด ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ํ์ด๋ฒ ์ด์์ ์ฟํฌ๋ก๋ก ๋นํ.
8-11์ผ์ฐจ: 4์ผ๊ฐ ์ฟํฌ๋ก ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ์ฟํฌ๋ก์์ ๊ด์ฃผ๋ก ๋นํ.
11-14์ผ์ฐจ: 4์ผ๊ฐ ๊ด์ฃผ ๋ฐฉ๋ฌธ.
14์ผ์ฐจ: ๊ด์ฃผ์์ ์ฐํ์ผ๋ก ๋นํ.
14-18์ผ์ฐจ: 5์ผ๊ฐ ์ฐํ ๋ฐฉ๋ฌธ.
18์ผ์ฐจ: ์ฐํ์์ ๋ฏ๋ฆ์ผ๋ก ๋นํ.
18-23์ผ์ฐจ: 6์ผ๊ฐ ๋ฏ๋ฆ ๋ฐฉ๋ฌธ.
|
85
|
์์์
| 3
|
์ง์ ์์ฑ
|
์ด 6์ผ ๋์ ์์์ 3๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ๋ฆฌ์ผ๋์ ํํธ๋ผ์ ๊ฐ๊ฐ 3์ผ์ฉ ๋จธ๋ฌผ๊ณ ์ถ์ต๋๋ค. ์ฌํ 2์ผ์ฐจ์ 4์ผ์ฐจ ์ฌ์ด์๋ ๋ฆฌ์ผ๋์ ๋จธ๋ฌผ๊ณ ์ถ์ต๋๋ค. 2์ผ ๋์ ๋๋ฐ์ด์ ๋ฐฉ๋ฌธํ๊ณ ์ถ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ฆฌ์ผ๋์ ๋๋ฐ์ด, ํํธ๋ผ์ ๋ฆฌ์ผ๋.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 6์ผ ๋์ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ๋๋ฐ์ด ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ๋๋ฐ์ด์์ ๋ฆฌ์ผ๋๋ก ๋นํ.
2-4์ผ์ฐจ: 3์ผ๊ฐ ๋ฆฌ์ผ๋ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ๋ฆฌ์ผ๋์์ ํํธ๋ผ๋ก ๋นํ.
4-6์ผ์ฐจ: 3์ผ๊ฐ ํํธ๋ผ ๋ฐฉ๋ฌธ.
|
You plan to visit 3 cities in Asia for a total of 6 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to stay in Riyadh and Petra for 3 days each. You want to stay in Riyadh between days 2 and 4 of your trip. You want to visit Dubai for 2 days.
Here are the cities that have direct flights: Riyadh and Dubai, Petra and Riyadh.
Plan a trip to visit the three cities in 6 days using direct flights.
|
Day 1-2: Visit Dubai for 2 days.
Day 2: Fly from Dubai to Riyadh.
Days 2-4: Visit Riyadh for 3 days.
Day 4: Fly from Riyadh to Petra.
Days 4-6: Visit Petra for 3 days.
|
๋ณ์ ์ ์:
R: ๋ฆฌ์ผ๋, P: ํํธ๋ผ, D: ๋๋ฐ์ด
a_R: ๋ฆฌ์ผ๋ ๋์ฐฉ์ผ, d_R: ๋ฆฌ์ผ๋ ์ถ๋ฐ์ผ
a_P: ํํธ๋ผ ๋์ฐฉ์ผ, d_P: ํํธ๋ผ ์ถ๋ฐ์ผ
a_D: ๋๋ฐ์ด ๋์ฐฉ์ผ, d_D: ๋๋ฐ์ด ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_R - a_R + 1 = 3
d_P - a_P + 1 = 3
d_D - a_D + 1 = 2
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_R, d_P, d_D) - min(a_R, a_P, a_D) + 1 = 6
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[2, 4] โฉ [a_R, d_R] โ โ
์งํญํธ์ด ์๋ ๋์:
(R โ D), (P โ R)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ๋๋ฐ์ด ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ๋๋ฐ์ด์์ ๋ฆฌ์ผ๋๋ก ๋นํ.
2-4์ผ์ฐจ: 3์ผ๊ฐ ๋ฆฌ์ผ๋ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ๋ฆฌ์ผ๋์์ ํํธ๋ผ๋ก ๋นํ.
4-6์ผ์ฐจ: 3์ผ๊ฐ ํํธ๋ผ ๋ฐฉ๋ฌธ.
|
86
|
์์์
| 3
|
์ง์ ์์ฑ
|
์ด 9์ผ ๋์ ์์์ 3๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ํ๋ฅดํฌ์ค์ 4์ผ๊ฐ ๋จธ๋ฌด๋ฅผ ๊ฒ์
๋๋ค. ํ์ดํ๋ฅผ 3์ผ๊ฐ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. 3์ผ์ฐจ์ ํ์ดํ์์ ๋ถ๋ชจ๋์ ๋ง๋ ๊ฒ์
๋๋ค. 4์ผ ๋์ ์๋์ ์์ ๊ฒ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ํ๋ฅดํฌ์ค์ ์๋, ์๋๊ณผ ํ์ดํ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 9์ผ ๋์ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ํ์ดํ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ํ์ดํ์์ ์๋์ผ๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ์๋ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์๋์์ ํ๋ฅดํฌ์ค๋ก ๋นํ.
6-9์ผ์ฐจ: 4์ผ๊ฐ ํ๋ฅดํฌ์ค ๋ฐฉ๋ฌธ.
|
You plan to visit 3 cities in Asia for a total of 9 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You will be in Tartus for 4 days. You will visit Haifa for 3 days. You will meet your parents in Haifa on day 3. You will be in Sidon for 4 days.
Here are the cities that have direct flights: Tartus and Sidon, Sidon and Haifa.
Plan a trip to visit these three cities in 9 days using direct flights.
|
Days 1-3: Visit Haifa for 3 days.
Day 3: Fly from Haifa to Sidon.
Days 3-6: Visit Sidon for 4 days.
Day 6: Fly from Sidon to Tartus.
Days 6-9: Visit Tartus for 4 days.
|
๋ณ์ ์ ์:
T: ํ๋ฅดํฌ์ค, H: ํ์ดํ, S: ์๋
a_T: ํ๋ฅดํฌ์ค ๋์ฐฉ์ผ, d_T: ํ๋ฅดํฌ์ค ์ถ๋ฐ์ผ
a_H: ํ์ดํ ๋์ฐฉ์ผ, d_H: ํ์ดํ ์ถ๋ฐ์ผ
a_S: ์๋ ๋์ฐฉ์ผ, d_S: ์๋ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_T - a_T + 1 = 4
d_H - a_H + 1 = 3
d_S - a_S + 1 = 4
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_T, d_H, d_S) - min(a_T, a_H, a_S) + 1 = 9
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
a_H โค 3 โค d_H
์งํญํธ์ด ์๋ ๋์:
(T โ S), (S โ H)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ํ์ดํ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ํ์ดํ์์ ์๋์ผ๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ์๋ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์๋์์ ํ๋ฅดํฌ์ค๋ก ๋นํ.
6-9์ผ์ฐจ: 4์ผ๊ฐ ํ๋ฅดํฌ์ค ๋ฐฉ๋ฌธ.
|
87
|
์์์
| 3
|
์ง์ ์์ฑ
|
์ด 8์ผ ๋์ ์์์ 3๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์นํ๊ณต์์ 3์ผ์ ๋ณด๋ผ ๊ฒ์
๋๋ค. ์์ดํธ๋ฅด์์ 5์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. ์นดํธ๋ง๋์์๋ 2์ผ์ ๋จธ๋ฌด๋ฅผ ์์ ์
๋๋ค. ๋จธ๋ฌด๋ฅด๋ ๊ธฐ๊ฐ์ด ๊ฐ์ฅ ์งง์ ๋์๋ฅผ ์ฒซ๋ฒ์งธ ์ฌํ์ง๋ก ์ผ๊ณ ์ถ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ์นํ๊ณต๊ณผ ์์ดํธ๋ฅด, ์นดํธ๋ง๋์ ์์ดํธ๋ฅด.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 8์ผ ๋์ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ์นดํธ๋ง๋ ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ์นดํธ๋ง๋์์ ์์ดํธ๋ฅด๋ก ๋นํ.
2-6์ผ์ฐจ: 5์ผ๊ฐ ์์ดํธ๋ฅด ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์์ดํธ๋ฅด์์ ์นํ๊ณต์ผ๋ก ๋นํ.
6-8์ผ์ฐจ: 3์ผ๊ฐ ์นํ๊ณต ๋ฐฉ๋ฌธ.
|
You plan to visit 3 cities in Asia for a total of 8 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You will spend 3 days in Chittagong. You want to spend 5 days in Jaipur. You'll spend 2 days in Kathmandu. You want to make the city where you will stay the shortest your first destination.
Here are the cities that have direct flights: Chittagong and Jaipur, Kathmandu and Jaipur.
Plan a trip to visit the three cities in 8 days using direct flights.
|
Day 1-2: Visit Kathmandu for 2 days.
Day 2: Fly from Kathmandu to Jaipur.
Days 2-6: Visit Jaipur for 5 days.
Day 6: Fly from Jaipur to Chittagong.
Days 6-8: Visit Chittagong for 3 days.
|
๋ณ์ ์ ์:
C: ์นํ๊ณต, J: ์์ดํธ๋ฅด, K: ์นดํธ๋ง๋
a_C: ์นํ๊ณต ๋์ฐฉ์ผ, d_C: ์นํ๊ณต ์ถ๋ฐ์ผ
a_J: ์์ดํธ๋ฅด ๋์ฐฉ์ผ, d_J: ์์ดํธ๋ฅด ์ถ๋ฐ์ผ
a_K: ์นดํธ๋ง๋ ๋์ฐฉ์ผ, d_K: ์นดํธ๋ง๋ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_C - a_C + 1 = 3
d_J - a_J + 1 = 5
d_K - a_K + 1 = 2
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_C, d_J, d_K) - min(a_C, a_J, a_K) + 1 = 8
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
min(a_C, a_J, a_K) = a_K
์งํญํธ์ด ์๋ ๋์:
(C โ J), (K โ J)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ์นดํธ๋ง๋ ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ์นดํธ๋ง๋์์ ์์ดํธ๋ฅด๋ก ๋นํ.
2-6์ผ์ฐจ: 5์ผ๊ฐ ์์ดํธ๋ฅด ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์์ดํธ๋ฅด์์ ์นํ๊ณต์ผ๋ก ๋นํ.
6-8์ผ์ฐจ: 3์ผ๊ฐ ์นํ๊ณต ๋ฐฉ๋ฌธ.
|
88
|
์์์
| 3
|
์ง์ ์์ฑ
|
์ด 9์ผ ๋์ ์์์ 3๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ํญ์ ์ฐ์์ 4์ผ์ ๋ณด๋ผ ๊ฒ์
๋๋ค. 6-8์ผ ์ฌ์ด์ ํญ์ ์ฐ์์ ์ด๋ฆฌ๋ ํํ์ ์ฐธ์ํ ๊ฒ์
๋๋ค. ๋ค์นด์์ 2์ผ์ ๋จธ๋ฌด๋ฅผ ์์ ์
๋๋ค. 5์ผ๊ฐ ๋ถ์ฐ์ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ํญ์ ์ฐ์ ๋ถ์ฐ, ๋ค์นด์ ๋ถ์ฐ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 9์ผ ๋์ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ๋ค์นด ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ๋ค์นด์์ ๋ถ์ฐ์ผ๋ก ๋นํ.
2-6์ผ์ฐจ: 5์ผ๊ฐ ๋ถ์ฐ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋ถ์ฐ์์ ํญ์ ์ฐ๋ก ๋นํ.
6-9์ผ์ฐจ: 4์ผ๊ฐ ํญ์ ์ฐ ๋ฐฉ๋ฌธ.
|
You plan to visit 3 cities in Asia for a total of 9 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You will spend 4 days in Hangzhou. You will attend a conference in Hangzhou between days 6-8. You will spend 2 days in Dhaka. You will be traveling to Busan for 5 days.
Here are the cities that have direct flights: Hangzhou and Busan, Dhaka and Busan.
Plan a trip to visit the three cities in 9 days using direct flights.
|
Days 1-2: Visit Dhaka for 2 days.
Day 2: Fly from Dhaka to Busan.
Days 2-6: Visit Busan for 5 days.
Day 6: Fly from Busan to Hangzhou.
Days 6-9: Visit Hangzhou for 4 days.
|
๋ณ์ ์ ์:
H: ํญ์ ์ฐ, D: ๋ค์นด, B: ๋ถ์ฐ
a_H: ํญ์ ์ฐ ๋์ฐฉ์ผ, d_H: ํญ์ ์ฐ ์ถ๋ฐ์ผ
a_D: ๋ค์นด ๋์ฐฉ์ผ, d_D: ๋ค์นด ์ถ๋ฐ์ผ
a_B: ๋ถ์ฐ ๋์ฐฉ์ผ, d_B: ๋ถ์ฐ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_H - a_H + 1 = 4
d_D - a_D + 1 = 2
d_B - a_B + 1 = 5
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_H, d_D, d_B) - min(a_H, a_D, a_B) + 1 = 9
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[6, 8] โฉ [a_H, d_H] โ โ
์งํญํธ์ด ์๋ ๋์:
(H โ B), (D โ B)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ธ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-2์ผ์ฐจ: 2์ผ๊ฐ ๋ค์นด ๋ฐฉ๋ฌธ.
2์ผ์ฐจ: ๋ค์นด์์ ๋ถ์ฐ์ผ๋ก ๋นํ.
2-6์ผ์ฐจ: 5์ผ๊ฐ ๋ถ์ฐ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋ถ์ฐ์์ ํญ์ ์ฐ๋ก ๋นํ.
6-9์ผ์ฐจ: 4์ผ๊ฐ ํญ์ ์ฐ ๋ฐฉ๋ฌธ.
|
89
|
์์์
| 4
|
์ง์ ์์ฑ
|
์ด 11์ผ ๋์ ์์์ 4๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. 5์ผ ๋์ ๋์ง์์ ๋จธ๋ฌด๋ฅผ ๊ฒ์
๋๋ค. ํฌ์นด๋ผ์์ 2์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. ์๋งํฐ์์ 3์ผ์ ๋ณด๋ผ ๊ฒ์
๋๋ค. 4์ผ๊ฐ ์ธ๋๋ฐํ ๋ฅด๋ฅผ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. ์ฌํ 3์ผ์ฐจ์ 6์ผ์ฐจ ์ฌ์ด์ ์ธ๋๋ฐํ ๋ฅด ์๋ด ํฌ์ด๋ฅผ ํ ๊ฒ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ์ธ๋๋ฐํ ๋ฅด์ ์๋งํฐ, ๋์ง์ ์ธ๋๋ฐํ ๋ฅด, ํฌ์นด๋ผ์ ๋์ง.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 11์ผ ๋์ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ์๋งํฐ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ์๋งํฐ์์ ์ธ๋๋ฐํ ๋ฅด๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ์ธ๋๋ฐํ ๋ฅด ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์ธ๋๋ฐํ ๋ฅด์์ ๋์ง์ผ๋ก ๋นํ.
6-10์ผ์ฐจ: 5์ผ๊ฐ ๋์ง ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ๋์ง์์ ํฌ์นด๋ผ๋ก ๋นํ.
10-11์ผ์ฐจ: 2์ผ๊ฐ ํฌ์นด๋ผ ๋ฐฉ๋ฌธ.
|
You plan to visit 4 cities in Asia for a total of 11 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'll be in Nanjing for 5 days. You'd like to spend 2 days in Pokhara. You will spend 3 days in Almaty. You will visit Ulaanbaatar for 4 days. You will take a city tour of Ulaanbaatar between days 3 and 6 of your trip.
Here are the cities that have direct flights: Ulaanbaatar and Almaty, Nanjing and Ulaanbaatar, Pokhara and Nanjing.
Plan your trip to visit four cities in 11 days with direct flights.
|
Days 1-3: Visit Almaty for 3 days.
Day 3: Fly from Almaty to Ulaanbaatar.
Days 3-6: Visit Ulaanbaatar for 4 days.
Day 6: Fly from Ulaanbaatar to Nanjing.
Days 6-10: Visit Nanjing for 5 days.
Day 10: Fly from Nanjing to Pokhara.
Days 10-11: Visit Pokhara for 2 days.
|
๋ณ์ ์ ์:
N: ๋์ง, P: ํฌ์นด๋ผ, A: ์๋งํฐ, U: ์ธ๋๋ฐํ ๋ฅด
a_N: ๋์ง ๋์ฐฉ์ผ, d_N: ๋์ง ์ถ๋ฐ์ผ
a_P: ํฌ์นด๋ผ ๋์ฐฉ์ผ, d_P: ํฌ์นด๋ผ ์ถ๋ฐ์ผ
a_A: ์๋งํฐ ๋์ฐฉ์ผ, d_A: ์๋งํฐ ์ถ๋ฐ์ผ
a_U: ์ธ๋๋ฐํ ๋ฅด ๋์ฐฉ์ผ, d_U: ์ธ๋๋ฐํ ๋ฅด ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_N - a_N + 1 = 5
d_P - a_P + 1 = 2
d_A - a_A + 1 = 3
d_U - a_U + 1 = 4
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_N, d_P, d_A, d_U) - min(a_N, a_P, a_A, a_U) + 1 = 11
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[3, 6] โฉ [a_U, d_U] โ โ
์งํญํธ์ด ์๋ ๋์:
(U โ A), (N โ U), (P โ N)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ์๋งํฐ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ์๋งํฐ์์ ์ธ๋๋ฐํ ๋ฅด๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ์ธ๋๋ฐํ ๋ฅด ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์ธ๋๋ฐํ ๋ฅด์์ ๋์ง์ผ๋ก ๋นํ.
6-10์ผ์ฐจ: 5์ผ๊ฐ ๋์ง ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ๋์ง์์ ํฌ์นด๋ผ๋ก ๋นํ.
10-11์ผ์ฐจ: 2์ผ๊ฐ ํฌ์นด๋ผ ๋ฐฉ๋ฌธ.
|
90
|
์์์
| 4
|
์ง์ ์์ฑ
|
์ด 13์ผ ๋์ ์์์ 4๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์์์นด๋ฐํธ์์ 7์ผ ๋์ ๋จธ๋ฌผ ์์ ์
๋๋ค. 2์ผ ๋์ ์๋ ๋ฐ์์ ๋จธ๋ฌผ ๊ฒ์
๋๋ค. 4-5์ผ์ฐจ์ ์๋ ๋ฐ์ ๊ด๊ดํ๊ณ ์ถ์ต๋๋ค. ๋ฐ์ฟ ์์ 3์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. 4์ผ๊ฐ ์์คํ๋๋ฅผ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ฐ์ฟ ์ ์์์นด๋ฐํธ, ์๋ ๋ฐ๊ณผ ์์คํ๋, ๋ฐ์ฟ ์ ์์คํ๋, ๋ฐ์ฟ ์ ์๋ ๋ฐ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 13์ผ ๋์ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ์์คํ๋ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ์์คํ๋์์ ์๋ ๋ฐ์ผ๋ก ๋นํ.
4-5์ผ์ฐจ: 2์ผ๊ฐ ์๋ ๋ฐ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ์๋ ๋ฐ์์ ๋ฐ์ฟ ๋ก ๋นํ.
5-7์ผ์ฐจ: 3์ผ๊ฐ ๋ฐ์ฟ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ๋ฐ์ฟ ์์ ์์์นด๋ฐํธ๋ก ๋นํ.
7-13์ผ์ฐจ: 7์ผ๊ฐ ์์์นด๋ฐํธ ๋ฐฉ๋ฌธ.
|
You plan to visit 4 cities in Asia for a total of 13 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You will be staying in Ashgabat for 7 days. You'll be in Yerevan for 2 days. You would like to tour Yerevan on days 4 and 5 of your trip. You want to spend 3 days in Baku. You will visit Astana on day 4.
Here are the cities that have direct flights: Baku and Ashkabat, Yerevan and Astana, Baku and Astana, Baku and Yerevan.
Plan a trip to visit four cities in 13 days using direct flights.
|
Days 1-4: Visit Astana for 4 days.
Day 4: Fly from Astana to Yerevan.
Days 4-5: Visit Yerevan for 2 days.
Day 5: Fly from Yerevan to Baku.
Days 5-7: Visit Baku for 3 days.
Day 7: Fly from Baku to Ashkabat.
Days 7-13: Visit Ashkabat for 7 days.
|
๋ณ์ ์ ์:
A: ์์์นด๋ฐํธ, Y: ์๋ ๋ฐ, B: ๋ฐ์ฟ , S: ์์คํ๋
a_A: ์์์นด๋ฐํธ ๋์ฐฉ์ผ, d_A: ์์์นด๋ฐํธ ์ถ๋ฐ์ผ
a_Y: ์๋ ๋ฐ ๋์ฐฉ์ผ, d_Y: ์๋ ๋ฐ ์ถ๋ฐ์ผ
a_B: ๋ฐ์ฟ ๋์ฐฉ์ผ, d_B: ๋ฐ์ฟ ์ถ๋ฐ์ผ
a_S: ์์คํ๋ ๋์ฐฉ์ผ, d_S: ์์คํ๋ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_A - a_A + 1 = 7
d_Y - a_Y + 1 = 2
d_B - a_B + 1 = 3
d_S - a_S + 1 = 4
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_A, d_Y, d_B, d_S) - min(a_A, a_Y, a_B, a_S) + 1 = 13
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
{4, 5} โ [a_Y, d_Y]
์งํญํธ์ด ์๋ ๋์:
(B โ A), (Y โ S), (B โ S), (B โ Y)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ์์คํ๋ ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ์์คํ๋์์ ์๋ ๋ฐ์ผ๋ก ๋นํ.
4-5์ผ์ฐจ: 2์ผ๊ฐ ์๋ ๋ฐ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ์๋ ๋ฐ์์ ๋ฐ์ฟ ๋ก ๋นํ.
5-7์ผ์ฐจ: 3์ผ๊ฐ ๋ฐ์ฟ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ๋ฐ์ฟ ์์ ์์์นด๋ฐํธ๋ก ๋นํ.
7-13์ผ์ฐจ: 7์ผ๊ฐ ์์์นด๋ฐํธ ๋ฐฉ๋ฌธ.
|
91
|
์์์
| 4
|
์ง์ ์์ฑ
|
์ด 11์ผ ๋์ ์์์ 4๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. 5์ผ๊ฐ ๋ํ์์ ๋จธ๋ฌผ๊ณ ์ถ์ต๋๋ค. 5-8์ผ์ ๋ํ์์ ์น๊ตฌ์ ์ฌํ์ ์ฆ๊ธฐ๊ธฐ๋ก ํ์ต๋๋ค. ๋ง๋๋ง์์ 2์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. ๋ฆฌ์ผ๋๋ฅผ 4์ผ๊ฐ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. 3์ผ ๋์ ์ฟ ์จ์ดํธ์ ์์ ์์ ์
๋๋ค. 2์ผ๊ณผ 3์ผ ์ฌ์ด์ ์ฟ ์จ์ดํธ์์ ๋น์ฆ๋์ค ๋ฏธํ
์ด ์์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ํ์ ๋ฆฌ์ผ๋, ๋ง๋๋ง์ ๋ํ, ๋ง๋๋ง์ ๋ฆฌ์ผ๋, ์ฟ ์จ์ดํธ์ ๋ง๋๋ง, ์ฟ ์จ์ดํธ์ ๋ํ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 11์ผ ๋์ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ์ฟ ์จ์ดํธ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ์ฟ ์จ์ดํธ์์ ๋ง๋๋ง๋ก ๋นํ.
3-4์ผ์ฐจ: 2์ผ๊ฐ ๋ง๋๋ง ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ๋ง๋๋ง์์ ๋ํ๋ก ๋นํ.
4-8์ผ์ฐจ: 5์ผ๊ฐ ๋ํ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ๋ํ์์ ๋ฆฌ์ผ๋๋ก ๋นํ.
8-11์ผ์ฐจ: 4์ผ๊ฐ ๋ฆฌ์ผ๋ ๋ฐฉ๋ฌธ.
|
You plan to visit 4 cities in Asia for a total of 11 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to stay in Doha for 5 days. You have planned to enjoy a trip with a friend in Doha from days 5 to 8. You want to spend 2 days in Manama. You're traveling to Riyadh for 4 days. You'll be in Kuwait for 3 days. You have a business meeting in Kuwait between days 2 and 3.
Here are the cities that have direct flights: Doha and Riyadh, Manama and Doha, Manama and Riyadh, Kuwait and Manama, Kuwait and Doha.
Plan a trip to visit four cities in 11 days with direct flights.
|
Days 1-3: Visit Kuwait for 3 days.
Day 3: Fly from Kuwait to Manama.
Days 3-4: Visit Manama for 2 days.
Day 4: Fly from Manama to Doha.
Days 4-8: Visit Doha for 5 days.
Day 8: Fly from Doha to Riyadh.
Days 8-11: Visit Riyadh for 4 days.
|
๋ณ์ ์ ์:
D: ๋ํ, M: ๋ง๋๋ง, R: ๋ฆฌ์ผ๋, K: ์ฟ ์จ์ดํธ
a_D: ๋ํ ๋์ฐฉ์ผ, d_D: ๋ํ ์ถ๋ฐ์ผ
a_M: ๋ง๋๋ง ๋์ฐฉ์ผ, d_M: ๋ง๋๋ง ์ถ๋ฐ์ผ
a_R: ๋ฆฌ์ผ๋ ๋์ฐฉ์ผ, d_R: ๋ฆฌ์ผ๋ ์ถ๋ฐ์ผ
a_K: ์ฟ ์จ์ดํธ ๋์ฐฉ์ผ, d_K: ์ฟ ์จ์ดํธ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_D - a_D + 1 = 5
d_M - a_M + 1 = 2
d_R - a_R + 1 = 4
d_K - a_K + 1 = 3
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_D, d_M, d_R, d_K) - min(a_D, a_M, a_R, a_K) + 1 = 11
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[5, 8] โฉ [a_D, d_D] โ โ
{2, 3} โฉ [a_K, d_K] โ โ
์งํญํธ์ด ์๋ ๋์:
(D โ R), (M โ D), (M โ R), (K โ M), (K โ D)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ์ฟ ์จ์ดํธ ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ์ฟ ์จ์ดํธ์์ ๋ง๋๋ง๋ก ๋นํ.
3-4์ผ์ฐจ: 2์ผ๊ฐ ๋ง๋๋ง ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ๋ง๋๋ง์์ ๋ํ๋ก ๋นํ.
4-8์ผ์ฐจ: 5์ผ๊ฐ ๋ํ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ๋ํ์์ ๋ฆฌ์ผ๋๋ก ๋นํ.
8-11์ผ์ฐจ: 4์ผ๊ฐ ๋ฆฌ์ผ๋ ๋ฐฉ๋ฌธ.
|
92
|
์์์
| 4
|
์ง์ ์์ฑ
|
์ด 14์ผ ๋์ ์์์ 4๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ๋ฐ๋ผ๋์์์ 5์ผ์ ๋ณด๋ผ ๊ฒ์
๋๋ค. 2์ผ๊ฐ ํํธ๋ฅผ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. ์นํ๊ณต์์ 3์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. 5์ผ๊ณผ 7์ผ ์ฌ์ด์ ์นํ๊ณต์ ์๋ ๋์์ ์ง์ ๋ฐฉ๋ฌธํ๊ธฐ๋ก ํ์ต๋๋ค. 7์ผ ๋์ ์นดํธ๋ง๋๋ฅผ ์ฆ๊ธฐ๊ณ ์ถ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ํํธ์ ์นดํธ๋ง๋, ๋ฐ๋ผ๋์์ ์นํ๊ณต, ๋ฐ๋ผ๋์์ ํํธ, ์นํ๊ณต๊ณผ ํํธ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 14์ผ ๋์ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ๋ฐ๋ผ๋์ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋ฐ๋ผ๋์์์ ์นํ๊ณต์ผ๋ก ๋นํ.
5-7์ผ์ฐจ: 3์ผ๊ฐ ์นํ๊ณต ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ์นํ๊ณต์์ ํํธ๋ก ๋นํ.
7-8์ผ์ฐจ: 2์ผ๊ฐ ํํธ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ํํธ์์ ์นดํธ๋ง๋๋ก ๋นํ.
8-14์ผ์ฐจ: 7์ผ๊ฐ ์นดํธ๋ง๋ ๋ฐฉ๋ฌธ.
|
You plan to visit 4 cities in Asia for a total of 14 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'll spend 5 days in Varanasi. You'll visit Thimphu for 2 days. You'd like to spend 3 days in Chittagong. You've decided to visit your brother's house in Chittagong between days 5 and 7. You'd like to enjoy Kathmandu for 7 days.
Here are the cities that have direct flights: Thimphu and Kathmandu, Varanasi and Chittagong, Varanasi and Thimphu, Chittagong and Thimphu.
Plan a trip to visit four cities in 14 days using direct flights.
|
Days 1-5: Visit Varanasi for 5 days.
Day 5: Fly from Varanasi to Chittagong.
Days 5-7: Visit Chittagong for 3 days.
Day 7: Fly from Chittagong to Thimphu.
Days 7-8: Visit Thimphu for 2 days.
Day 8: Fly from Thimphu to Kathmandu.
Days 8-14: Visit Kathmandu for 7 days.
|
๋ณ์ ์ ์:
V: ๋ฐ๋ผ๋์, T: ํํธ, C: ์นํ๊ณต, K: ์นดํธ๋ง๋
a_V: ๋ฐ๋ผ๋์ ๋์ฐฉ์ผ, d_V: ๋ฐ๋ผ๋์ ์ถ๋ฐ์ผ
a_T: ํํธ ๋์ฐฉ์ผ, d_T: ํํธ ์ถ๋ฐ์ผ
a_C: ์นํ๊ณต ๋์ฐฉ์ผ, d_C: ์นํ๊ณต ์ถ๋ฐ์ผ
a_K: ์นดํธ๋ง๋ ๋์ฐฉ์ผ, d_K: ์นดํธ๋ง๋ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_V - a_V + 1 = 5
d_T - a_T + 1 = 2
d_C - a_C + 1 = 3
d_K - a_K + 1 = 7
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_V, d_T, d_C, d_K) - min(a_V, a_T, a_C, a_K) + 1 = 14
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[5, 7] โฉ [a_C, d_C] โ โ
์งํญํธ์ด ์๋ ๋์:
(T โ K), (V โ C), (V โ T), (C โ T)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ๋ฐ๋ผ๋์ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋ฐ๋ผ๋์์์ ์นํ๊ณต์ผ๋ก ๋นํ.
5-7์ผ์ฐจ: 3์ผ๊ฐ ์นํ๊ณต ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ์นํ๊ณต์์ ํํธ๋ก ๋นํ.
7-8์ผ์ฐจ: 2์ผ๊ฐ ํํธ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ํํธ์์ ์นดํธ๋ง๋๋ก ๋นํ.
8-14์ผ์ฐจ: 7์ผ๊ฐ ์นดํธ๋ง๋ ๋ฐฉ๋ฌธ.
|
93
|
์์์
| 5
|
์ง์ ์์ฑ
|
์ด 18์ผ ๋์ ์์์ 5๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์๊ณค์์ 3์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. ์๊ณค์ด ์ฌํ์ ์์์ด์์ผ๋ฉด ์ข๊ฒ ์ต๋๋ค. ํํ์ผ์์ 5์ผ๊ฐ ๋จธ๋ฌผ๊ณ ์ถ์ต๋๋ค. 3์ผ๊ฐ ํ๋ํ์ ์์ ์์ ์
๋๋ค. ๋ฐฉ๋น์ฅ์์ 4์ผ ๋์ ๋จธ๋ฌผ๊ณ ์ถ์ต๋๋ค. ์ฌํ 4์ผ์ฐจ์ 5์ผ์ฐจ ์ฌ์ด์ ๋ฐฉ๋น์ฅ์์ ์น๊ตฌ๋ฅผ ๋ง๋ ์ฌํ์ ๊ฐ์ด ํ๊ธฐ๋ก ํ์ต๋๋ค. ํธ์น๋ฏผ์์ 7์ผ ๋์ ๋จธ๋ฌผ ์์ ์
๋๋ค. 10์ผ๊ณผ 15์ผ ์ฌ์ด์ ํธ์น๋ฏผ ํฌ๋ฃจ์ฆ ํฌ์ด๋ฅผ ์์ฝํด๋์์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ํ๋ํ๊ณผ ํธ์น๋ฏผ, ๋ฐฉ๋น์ฅ๊ณผ ํ๋ํ, ๋ฐฉ๋น์ฅ๊ณผ ์๊ณค, ํํ์ผ์ ๋ฐฉ๋น์ฅ, ์๊ณค๊ณผ ํธ์น๋ฏผ, ํธ์น๋ฏผ๊ณผ ํํ์ผ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 18์ผ ๋์ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ์๊ณค ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ์๊ณค์์ ๋ฐฉ๋น์ฅ์ผ๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ๋ฐฉ๋น์ฅ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋ฐฉ๋น์ฅ์์ ํํ์ผ๋ก ๋นํ.
6-10์ผ์ฐจ: 5์ผ๊ฐ ํํ์ผ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ํํ์ผ์์ ํธ์น๋ฏผ ๋นํ.
10-16์ผ์ฐจ: 7์ผ๊ฐ ํธ์น๋ฏผ ๋ฐฉ๋ฌธ.
16์ผ์ฐจ: ํธ์น๋ฏผ์์ ํ๋ํ์ผ๋ก ๋นํ.
16-18์ผ์ฐจ: 3์ผ๊ฐ ํ๋ํ ๋ฐฉ๋ฌธ.
|
You plan to visit 5 cities in Asia for a total of 18 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to spend 3 days in Yangon. You want Yangon to be the start of your trip. You want to spend 5 days in Pattaya. You'll be in Phnom Penh for 3 days. You'd like to spend 4 days in Vang Vieng. You're meeting a friend in Vang Vieng between days 4 and 5 of your trip. You'll be in Ho Chi Minh City for 7 days. You have booked a cruise tour of Ho Chi Minh City between days 10 and 15.
Here are the cities that have direct flights: Phnom Penh and Ho Chi Minh, Vang Vieng and Phnom Penh, Vang Vieng and Yangon, Pattaya and Vang Vieng, Yangon and Ho Chi Minh, Ho Chi Minh and Pattaya.
Plan a trip to visit five cities in 18 days with direct flights.
|
Days 1-3: Visit Yangon for 3 days.
Day 3: Fly from Yangon to Vang Vieng.
Days 3-6: Visit Vang Vieng for 4 days.
Day 6: Fly from Vang Vieng to Pattaya.
Days 6-10: Visit Pattaya for 5 days.
Day 10: Fly from Pattaya to Ho Chi Minh City.
Days 10-16: Visit Ho Chi Minh City for 7 days.
Day 16: Fly from Ho Chi Minh City to Phnom Penh.
Days 16-18: Visit Phnom Penh for 3 days.
|
๋ณ์ ์ ์:
Y: ์๊ณค, Pt: ํํ์ผ, Pn: ํ๋ํ, V: ๋ฐฉ๋น์ฅ, H: ํธ์น๋ฏผ
a_Y: ์๊ณค ๋์ฐฉ์ผ, d_Y: ์๊ณค ์ถ๋ฐ์ผ
a_Pt: ํํ์ผ ๋์ฐฉ์ผ, d_Pt: ํํ์ผ ์ถ๋ฐ์ผ
a_Pn: ํ๋ํ ๋์ฐฉ์ผ, d_Pn: ํ๋ํ ์ถ๋ฐ์ผ
a_V: ๋ฐฉ๋น์ฅ ๋์ฐฉ์ผ, d_V: ๋ฐฉ๋น์ฅ ์ถ๋ฐ์ผ
a_H: ํธ์น๋ฏผ ๋์ฐฉ์ผ, d_H: ํธ์น๋ฏผ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_Y - a_Y + 1 = 3
d_Pt - a_Pt + 1 = 5
d_Pn - a_Pn + 1 = 3
d_V - a_V + 1 = 4
d_H - a_H + 1 = 7
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_Y, d_Pt, d_Pn, d_V, d_H) - min(a_Y, a_Pt, a_Pn, a_V, a_H) + 1 = 18
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
a_Y = 1
{4, 5} โฉ [a_V, d_V] โ โ
[10, 15] โฉ [a_H, d_H] โ โ
์งํญํธ์ด ์๋ ๋์:
(Pn โ H), (V โ Pn), (V โ Y), (Pt โ V), (Y โ H), (H โ Pt)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ์๊ณค ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ์๊ณค์์ ๋ฐฉ๋น์ฅ์ผ๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ๋ฐฉ๋น์ฅ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋ฐฉ๋น์ฅ์์ ํํ์ผ๋ก ๋นํ.
6-10์ผ์ฐจ: 5์ผ๊ฐ ํํ์ผ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ํํ์ผ์์ ํธ์น๋ฏผ ๋นํ.
10-16์ผ์ฐจ: 7์ผ๊ฐ ํธ์น๋ฏผ ๋ฐฉ๋ฌธ.
16์ผ์ฐจ: ํธ์น๋ฏผ์์ ํ๋ํ์ผ๋ก ๋นํ.
16-18์ผ์ฐจ: 3์ผ๊ฐ ํ๋ํ ๋ฐฉ๋ฌธ.
|
94
|
์์์
| 5
|
์ง์ ์์ฑ
|
์ด 20์ผ ๋์ ์์์ 5๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ๋ง๋๋ผ์์ 6์ผ์ ๋ณด๋ด๊ณ ์ ํฉ๋๋ค. 17-19์ผ ์ฌ์ด์ ๋ง๋๋ผ ํฌ์ด ๋ฒ์ค๋ฅผ ์์ฝํด๋์์ต๋๋ค. 6์ผ๊ฐ ์์ก๋ฆฝ์ ์์ ์์ ์
๋๋ค. ์์นด๋ฅดํ์์ 5์ผ์ ๋จธ๋ฌผ ๊ฒ์
๋๋ค. 4์ผ๊ฐ ์ฑ๊ฐํฌ๋ฅด์์ ์ฌํ์ ์ฆ๊ธฐ๊ณ ์ถ์ต๋๋ค. 3์ผ ๋์ ์ฟ ์๋ผ๋ฃธํธ๋ฅด์ ๋จธ๋ฌผ๊ณ ์ถ์ต๋๋ค. 6์ผ๊ณผ 8์ผ ์ฌ์ด์ ์ฟ ์๋ผ๋ฃธํธ๋ฅด์์ ๋จธ๋ฌผ ์์๋ฅผ ๋ฏธ๋ฆฌ ์์ฝํด๋์์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ์์ ๋ฆฝ๊ณผ ์์นด๋ฅดํ, ์์ ๋ฆฝ๊ณผ ์ฑ๊ฐํฌ๋ฅด, ์์นด๋ฅดํ์ ๋ง๋๋ผ, ์ฑ๊ฐํฌ๋ฅด์ ์์นด๋ฅดํ, ์ฟ ์๋ผ๋ฃธํธ๋ฅด์ ์์ ๋ฆฝ, ์ฑ๊ฐํฌ๋ฅด์ ์ฟ ์๋ผ๋ฃธํธ๋ฅด.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 20์ผ ๋์ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-6์ผ์ฐจ: 6์ผ๊ฐ ์์ ๋ฆฝ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์์ ๋ฆฝ์์ ์ฟ ์๋ผ๋ฃธํธ๋ฅด๋ก ๋นํ.
6-8์ผ์ฐจ: 3์ผ๊ฐ ์ฟ ์๋ผ๋ฃธํธ๋ฅด ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ์ฟ ์๋ผ๋ฃธํธ๋ฅด์์ ์ฑ๊ฐํฌ๋ฅด๋ก ๋นํ.
8-11์ผ์ฐจ: 4์ผ๊ฐ ์ฑ๊ฐํฌ๋ฅด ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ์ฑ๊ฐํฌ๋ฅด์์ ์์นด๋ฅดํ ๋นํ.
11-15์ผ์ฐจ: 5์ผ๊ฐ ์์นด๋ฅดํ ๋ฐฉ๋ฌธ.
15์ผ์ฐจ: ์์นด๋ฅดํ์์ ๋ง๋๋ผ๋ก ๋นํ.
15-20์ผ์ฐจ: 6์ผ๊ฐ ๋ง๋๋ผ ๋ฐฉ๋ฌธ.
|
You plan to visit 5 cities in Asia for a total of 20 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to spend 6 days in Manila. You've booked a tour bus to Manila between days 17-19. You'll be in Siem Reap for 6 days. You'll spend 5 days in Jakarta. You'd like to spend 4 days in Singapore. You'd like to spend 3 days in Kuala Lumpur. You've pre-booked a place to stay in Kuala Lumpur between the 6th and 8th.
Here are the cities that have direct flights: Siem Reap and Jakarta, Siem Reap and Singapore, Jakarta and Manila, Singapore and Jakarta, Kuala Lumpur and Siem Reap, Singapore and Kuala Lumpur.
Plan a trip to visit five cities in 20 days with direct flights.
|
Days 1-6: Visit Siem Reap for 6 days.
Day 6: Fly from Siem Reap to Kuala Lumpur.
Days 6-8: Visit Kuala Lumpur for 3 days.
Day 8: Fly from Kuala Lumpur to Singapore.
Days 8-11: Visit Singapore for 4 days.
Day 11: Fly from Singapore to Jakarta.
Days 11-15: Visit Jakarta for 5 days.
Day 15: Fly from Jakarta to Manila.
Days 15-20: Visit Manila for 6 days.
|
๋ณ์ ์ ์:
M: ๋ง๋๋ผ, S: ์์ ๋ฆฝ, J: ์์นด๋ฅดํ, Si: ์ฑ๊ฐํฌ๋ฅด, K: ์ฟ ์๋ผ๋ฃธํธ๋ฅด
a_M: ๋ง๋๋ผ ๋์ฐฉ์ผ, d_M: ๋ง๋๋ผ ์ถ๋ฐ์ผ
a_S: ์์ ๋ฆฝ ๋์ฐฉ์ผ, d_S: ์์ ๋ฆฝ ์ถ๋ฐ์ผ
a_J: ์์นด๋ฅดํ ๋์ฐฉ์ผ, d_J: ์์นด๋ฅดํ ์ถ๋ฐ์ผ
a_Si: ์ฑ๊ฐํฌ๋ฅด ๋์ฐฉ์ผ, d_Si: ์ฑ๊ฐํฌ๋ฅด ์ถ๋ฐ์ผ
a_K: ์ฟ ์๋ผ๋ฃธํธ๋ฅด ๋์ฐฉ์ผ, d_K: ์ฟ ์๋ผ๋ฃธํธ๋ฅด ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_M - a_M + 1 = 6
d_S - a_S + 1 = 6
d_J - a_J + 1 = 5
d_Si - a_Si + 1 = 4
d_K - a_K + 1 = 3
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_M, d_S, d_J, d_Si, d_K) - min(a_M, a_S, a_J, a_Si, a_K) + 1 = 20
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[17, 19] โฉ [a_M, d_M] โ โ
[6, 8] โฉ [a_K, d_K] โ โ
์งํญํธ์ด ์๋ ๋์:
(S โ J), (S โ Si), (J โ M), (Si โ J), (K โ S), (Si โ K)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-6์ผ์ฐจ: 6์ผ๊ฐ ์์ ๋ฆฝ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์์ ๋ฆฝ์์ ์ฟ ์๋ผ๋ฃธํธ๋ฅด๋ก ๋นํ.
6-8์ผ์ฐจ: 3์ผ๊ฐ ์ฟ ์๋ผ๋ฃธํธ๋ฅด ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ์ฟ ์๋ผ๋ฃธํธ๋ฅด์์ ์ฑ๊ฐํฌ๋ฅด๋ก ๋นํ.
8-11์ผ์ฐจ: 4์ผ๊ฐ ์ฑ๊ฐํฌ๋ฅด ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ์ฑ๊ฐํฌ๋ฅด์์ ์์นด๋ฅดํ ๋นํ.
11-15์ผ์ฐจ: 5์ผ๊ฐ ์์นด๋ฅดํ ๋ฐฉ๋ฌธ.
15์ผ์ฐจ: ์์นด๋ฅดํ์์ ๋ง๋๋ผ๋ก ๋นํ.
15-20์ผ์ฐจ: 6์ผ๊ฐ ๋ง๋๋ผ ๋ฐฉ๋ฌธ.
|
95
|
์์์
| 5
|
์ง์ ์์ฑ
|
์ด 21์ผ ๋์ ์์์ 5๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. 5์ผ ๋์ ๊ฐ์ค์์์ ์๊ฐ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. 4์ผ๊ฐ ๊นํด๋ฅผ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. 7์ผ ๋์ ์ฑ๊ฐํฌ๋ฅด์์ ์ฌํ์ ํ๊ณ ์ถ์ต๋๋ค. ํ์ฟ ์ค์นด์์ 6์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. 4์ผ๊ณผ 8์ผ ์ฌ์ด์ ํ์ฟ ์ค์นด์์ ๋ฒ์ค ํฌ์ด๋ฅผ ํ๊ธฐ๋ก ํ์ต๋๋ค. 3์ผ๊ฐ ์ธ๋ถ์ ์์ ์์ ์
๋๋ค. 13-15์ผ ์ฌ์ด์ ์ธ๋ถ ํธํํฌ์ด๋ฅผ ์์ฝํด๋์์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๊ฐ์ค์๊ณผ ํ์ฟ ์ค์นด, ์ฑ๊ฐํฌ๋ฅด์ ์ธ๋ถ, ์ฑ๊ฐํฌ๋ฅด์ ํ์ฟ ์ค์นด, ์ธ๋ถ์ ๊นํด, ์ธ๋ถ์ ๊ฐ์ค์, ๊นํด์ ํ์ฟ ์ค์นด, ๊นํด์ ๊ฐ์ค์.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 21์ผ ๋์ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ๊นํด ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ๊นํด์์ ํ์ฟ ์ค์นด๋ก ๋นํ.
4-9์ผ์ฐจ: 6์ผ๊ฐ ํ์ฟ ์ค์นด ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ํ์ฟ ์ค์นด์์ ๊ฐ์ค์๋ก ๋นํ.
9-13์ผ์ฐจ: 5์ผ๊ฐ ๊ฐ์ค์ ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ๊ฐ์ค์์์ ์ธ๋ถ ๋นํ.
13-15์ผ์ฐจ: 3์ผ๊ฐ ์ธ๋ถ ๋ฐฉ๋ฌธ.
15์ผ์ฐจ: ์ธ๋ถ์์ ์ฑ๊ฐํฌ๋ฅด๋ก ๋นํ.
15-21์ผ์ฐจ: 7์ผ๊ฐ ์ฑ๊ฐํฌ๋ฅด ๋ฐฉ๋ฌธ.
|
You plan to visit 5 cities in Asia for a total of 21 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'd like to spend 5 days in Kaohsiung. You'll be visiting the Gimhae for 4 days. You'd like to spend 7 days in Singapore. You'd like to spend 6 days in Fukuoka. You've decided to take a bus tour in Fukuoka between the 4th and 8th. You'll be in Cebu for 3 days. You've booked a hopping tour of Cebu between days 13-15.
Here are the cities that have direct flights: Kaohsiung and Fukuoka, Singapore and Cebu, Singapore and Fukuoka, Cebu and Gimhae, Cebu and Kaohsiung, Gimhae and Fukuoka, Gimhae and Kaohsiung.
Plan a trip to visit five cities in 21 days with direct flights.
|
Days 1-4: Visit Gimhae for 4 days.
Day 4: Fly from Gimhae to Fukuoka.
Days 4-9: Visit Fukuoka for 6 days.
Day 9: Fly from Fukuoka to Kaohsiung.
Days 9-13: Visit Kaohsiung for 5 days.
Day 13: Fly from Kaohsiung to Cebu.
Days 13-15: Visit Cebu for 3 days.
Day 15: Fly from Cebu to Singapore.
Days 15-21: Visit Singapore for 7 days.
|
๋ณ์ ์ ์:
K: ๊ฐ์ค์, G: ๊นํด, S: ์ฑ๊ฐํฌ๋ฅด, F: ํ์ฟ ์ค์นด, C: ์ธ๋ถ
a_K: ๊ฐ์ค์ ๋์ฐฉ์ผ, d_K: ๊ฐ์ค์ ์ถ๋ฐ์ผ
a_G: ๊นํด ๋์ฐฉ์ผ, d_G: ๊นํด ์ถ๋ฐ์ผ
a_S: ์ฑ๊ฐํฌ๋ฅด ๋์ฐฉ์ผ, d_S: ์ฑ๊ฐํฌ๋ฅด ์ถ๋ฐ์ผ
a_F: ํ์ฟ ์ค์นด ๋์ฐฉ์ผ, d_F: ํ์ฟ ์ค์นด ์ถ๋ฐ์ผ
a_C: ์ธ๋ถ ๋์ฐฉ์ผ, d_C: ์ธ๋ถ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_K - a_K + 1 = 5
d_G - a_G + 1 = 4
d_S - a_S + 1 = 7
d_F - a_F + 1 = 6
d_C - a_C + 1 = 3
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_K, d_G, d_S, d_F, d_C) - min(a_K, a_G, a_S, a_F, a_C) + 1 = 21
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[4, 8] โฉ [a_F, d_F] โ โ
[13, 15] โฉ [a_C, d_C] โ โ
์งํญํธ์ด ์๋ ๋์:
(K โ F), (S โ C), (S โ F), (C โ G), (C โ K), (G โ F), (G โ K)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ๊นํด ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ๊นํด์์ ํ์ฟ ์ค์นด๋ก ๋นํ.
4-9์ผ์ฐจ: 6์ผ๊ฐ ํ์ฟ ์ค์นด ๋ฐฉ๋ฌธ.
9์ผ์ฐจ: ํ์ฟ ์ค์นด์์ ๊ฐ์ค์๋ก ๋นํ.
9-13์ผ์ฐจ: 5์ผ๊ฐ ๊ฐ์ค์ ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ๊ฐ์ค์์์ ์ธ๋ถ ๋นํ.
13-15์ผ์ฐจ: 3์ผ๊ฐ ์ธ๋ถ ๋ฐฉ๋ฌธ.
15์ผ์ฐจ: ์ธ๋ถ์์ ์ฑ๊ฐํฌ๋ฅด๋ก ๋นํ.
15-21์ผ์ฐจ: 7์ผ๊ฐ ์ฑ๊ฐํฌ๋ฅด ๋ฐฉ๋ฌธ.
|
96
|
์์์
| 5
|
์ง์ ์์ฑ
|
์ด 21์ผ ๋์ ์์์ 5๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ๋๋ฆฐ์์ 3์ผ์ ๋ณด๋ด๊ณ ์ ํฉ๋๋ค. 7์ผ๊ฐ ์๋งํฐ๋ฅผ ๋ฐฉ๋ฌธํ ์์ ์
๋๋ค. ๋์จ๋ฒ ์์ 4์ผ ๋์ ์์ ์์ ์
๋๋ค. 13์ผ๊ณผ 15์ผ ์ฌ์ด์๋ ๊ผญ ๋์จ๋ฒ ์ ์์ด์ผ ํฉ๋๋ค. ์นด๋ถ์์ 6์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. ์ฌ๋ง๋ฅด์นธํธ์์ 5์ผ์ ๋จธ๋ฌด๋ฅด๊ณ ์ถ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋์จ๋ฒ ์ ๋๋ฆฐ, ์นด๋ถ๊ณผ ๋์จ๋ฒ , ์ฌ๋ง๋ฅด์นธํธ์ ์๋งํฐ, ์ฌ๋ง๋ฅด์นธํธ์ ๋๋ฆฐ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 21์ผ ๋์ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-7์ผ์ฐจ: 7์ผ๊ฐ ์๋งํฐ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ์๋งํฐ์์ ์ฌ๋ง๋ฅด์นธํธ๋ก ๋นํ.
7-11์ผ์ฐจ: 5์ผ๊ฐ ์ฌ๋ง๋ฅด์นธํธ ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ์ฌ๋ง๋ฅด์นธํธ์์ ๋๋ฆฐ์ผ๋ก ๋นํ.
11-13์ผ์ฐจ: 3์ผ๊ฐ ๋๋ฆฐ ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ๋๋ฆฐ์์ ๋์จ๋ฒ ๋นํ.
13-16์ผ์ฐจ: 4์ผ๊ฐ ๋์จ๋ฒ ๋ฐฉ๋ฌธ.
16์ผ์ฐจ: ๋์จ๋ฒ ์์ ์นด๋ถ๋ก ๋นํ.
16-21์ผ์ฐจ: 6์ผ๊ฐ ์นด๋ถ ๋ฐฉ๋ฌธ.
|
You plan to visit 5 cities in Asia for a total of 21 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'll spend 3 days in Naryn. You'll visit Almaty for 7 days. You'll be in Dushanbe for 4 days. You must be in Dushanbe between the 13th and 15th. You want to spend 6 days in Kabul. You want to spend 5 days in Samarkand.
Here are the cities that have direct flights: Dushanbe and Naryn, Kabul and Dushanbe, Samarkand and Almaty, Samarkand and Naryn.
Plan a trip to visit five cities in 21 days with direct flights.
|
Days 1-7: Visit Almaty for 7 days.
Day 7: Fly from Almaty to Samarkand.
Days 7-11: Visit Samarkand for 5 days.
Day 11: Fly from Samarkand to Naryn.
Days 11-13: Visit Naryn for 3 days.
Day 13: Fly from Naryn to Dushanbe.
Days 13-16: Visit Dushanbe for 4 days.
Day 16: Fly from Dushanbe to Kabul.
Days 16-21: Visit Kabul for 6 days.
|
๋ณ์ ์ ์:
N: ๋๋ฆฐ, A: ์๋งํฐ, D: ๋์จ๋ฒ , K: ์นด๋ถ, S: ์ฌ๋ง๋ฅด์นธํธ
a_N: ๋๋ฆฐ ๋์ฐฉ์ผ, d_N: ๋๋ฆฐ ์ถ๋ฐ์ผ
a_A: ์๋งํฐ ๋์ฐฉ์ผ, d_A: ์๋งํฐ ์ถ๋ฐ์ผ
a_D: ๋์จ๋ฒ ๋์ฐฉ์ผ, d_D: ๋์จ๋ฒ ์ถ๋ฐ์ผ
a_K: ์นด๋ถ ๋์ฐฉ์ผ, d_K: ์นด๋ถ ์ถ๋ฐ์ผ
a_S: ์ฌ๋ง๋ฅด์นธํธ ๋์ฐฉ์ผ, d_S: ์ฌ๋ง๋ฅด์นธํธ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_N - a_N + 1 = 3
d_A - a_A + 1 = 7
d_D - a_D + 1 = 4
d_K - a_K + 1 = 6
d_S - a_S + 1 = 5
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_N, d_A, d_D, d_K, d_S) - min(a_N, a_A, a_D, a_K, a_S) + 1 = 21
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[13, 15] โฉ [a_D, d_D] โ โ
์งํญํธ์ด ์๋ ๋์:
(D โ N), (K โ D), (S โ A), (S โ N)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ๋ค์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-7์ผ์ฐจ: 7์ผ๊ฐ ์๋งํฐ ๋ฐฉ๋ฌธ.
7์ผ์ฐจ: ์๋งํฐ์์ ์ฌ๋ง๋ฅด์นธํธ๋ก ๋นํ.
7-11์ผ์ฐจ: 5์ผ๊ฐ ์ฌ๋ง๋ฅด์นธํธ ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ์ฌ๋ง๋ฅด์นธํธ์์ ๋๋ฆฐ์ผ๋ก ๋นํ.
11-13์ผ์ฐจ: 3์ผ๊ฐ ๋๋ฆฐ ๋ฐฉ๋ฌธ.
13์ผ์ฐจ: ๋๋ฆฐ์์ ๋์จ๋ฒ ๋นํ.
13-16์ผ์ฐจ: 4์ผ๊ฐ ๋์จ๋ฒ ๋ฐฉ๋ฌธ.
16์ผ์ฐจ: ๋์จ๋ฒ ์์ ์นด๋ถ๋ก ๋นํ.
16-21์ผ์ฐจ: 6์ผ๊ฐ ์นด๋ถ ๋ฐฉ๋ฌธ.
|
97
|
์์์
| 6
|
์ง์ ์์ฑ
|
์ด 22์ผ ๋์ ์์์ 6๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์ฟ ์จ์ดํธ์์ 7์ผ ๋์ ์ฌํ์ ํ๊ณ ์ถ์ต๋๋ค. 10-16์ผ ์ฌ์ด์ ์ฟ ์จ์ดํธ์์ ์ฌ์ฉํ ์๊ฐ์ฉ์ ๋น๋ ค๋์์ต๋๋ค. ๋๋ฐ์ด์์ 4์ผ์ ๋ณด๋ผ ๊ฒ์
๋๋ค. 2์ผ๊ฐ ์๋ด์์ ๋จธ๋ฌด๋ฅด๊ณ ์ ํฉ๋๋ค. ๋ฌดํ๋ผํฌ์์ 3์ผ์ ๋ณด๋ผ ์์ ์
๋๋ค. ๋ฉ์นด๋ฅผ 6์ผ ๋์ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. 5์ผ๊ฐ ๋ํ๋ฅผ ๋ฐฉ๋ฌธํ๋ ค๊ณ ํฉ๋๋ค. 7์ผ๊ณผ 8์ผ ์ฌ์ด์๋ ๋ํ์์ ์ถ๊ตฌ ๊ฒฝ๊ธฐ๋ฅผ ๋ณผ ๊ฒ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ฌดํ๋ผํฌ์ ๋ํ, ๋ฌดํ๋ผํฌ์ ์๋ด, ์ฟ ์จ์ดํธ์ ๋ฌดํ๋ผํฌ, ๋ฉ์นด์ ์ฟ ์จ์ดํธ, ์๋ด๊ณผ ๋ฉ์นด, ๋๋ฐ์ด์ ๋ฉ์นด, ๋๋ฐ์ด์ ๋ํ, ๋๋ฐ์ด์ ๋ฌดํ๋ผํฌ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 22์ผ ๋์ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ๋๋ฐ์ด ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ๋๋ฐ์ด์์ ๋ํ๋ก ๋นํ.
4-8์ผ์ฐจ: 5์ผ๊ฐ ๋ํ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ๋ํ์์ ๋ฌดํ๋ผํฌ๋ก ๋นํ.
8-10์ผ์ฐจ: 3์ผ๊ฐ ๋ฌดํ๋ผํฌ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ๋ฌดํ๋ผํฌ์์ ์ฟ ์จ์ดํธ๋ก ๋นํ.
10-16์ผ์ฐจ: 7์ผ๊ฐ ์ฟ ์จ์ดํธ ๋ฐฉ๋ฌธ.
16์ผ์ฐจ: ์ฟ ์จ์ดํธ์์ ๋ฉ์นด๋ก ๋นํ.
16-21์ผ์ฐจ: 6์ผ๊ฐ ๋ฉ์นด ๋ฐฉ๋ฌธ.
21์ผ์ฐจ: ๋ฉ์นด์์ ์๋ด์ผ๋ก ๋นํ.
21-22์ผ์ฐจ: 2์ผ๊ฐ ์๋ด ๋ฐฉ๋ฌธ.
|
You plan to visit 6 cities in Asia for a total of 22 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to spend 7 days in Kuwait. You've rented a car to use in Kuwait between days 10-16. You'll spend 4 days in Dubai. You want to spend 2 days in Aden. You'll spend 3 days in Muharraq. You're going to visit Mecca for 6 days. You're going to visit Doha for 5 days. You're going to watch a soccer game in Doha between the 7th and 8th.
Here are the cities that have direct flights: Muharraq and Doha, Muharraq and Aden, Kuwait and Muharraq, Mecca and Kuwait, Aden and Mecca, Dubai and Mecca, Dubai and Doha, Dubai and Muharraq.
Plan a trip to visit six cities in 22 days with direct flights.
|
Days 1-4: Visit Dubai for 4 days.
Day 4: Fly from Dubai to Doha.
Days 4-8: Visit Doha for 5 days.
Day 8: Fly from Doha to Muharraq.
Days 8-10: Visit Muharraq for 3 days.
Day 10: Fly from Muharraq to Kuwait.
Days 10-16: Visit Kuwait for 7 days.
Day 16: Fly from Kuwait to Mecca.
Days 16-21: Visit Mecca for 6 days.
Day 21: Fly from Mecca to Aden.
Days 21-22: Visit Aden for 2 days.
|
๋ณ์ ์ ์:
K: ์ฟ ์จ์ดํธ, D: ๋๋ฐ์ด, A: ์๋ด, M: ๋ฌดํ๋ผํฌ, E: ๋ฉ์นด, Q: ๋ํ
a_K: ์ฟ ์จ์ดํธ ๋์ฐฉ์ผ, d_K: ์ฟ ์จ์ดํธ ์ถ๋ฐ์ผ
a_D: ๋๋ฐ์ด ๋์ฐฉ์ผ, d_D: ๋๋ฐ์ด ์ถ๋ฐ์ผ
a_A: ์๋ด ๋์ฐฉ์ผ, d_A: ์๋ด ์ถ๋ฐ์ผ
a_M: ๋ฌดํ๋ผํฌ ๋์ฐฉ์ผ, d_M: ๋ฌดํ๋ผํฌ ์ถ๋ฐ์ผ
a_E: ๋ฉ์นด ๋์ฐฉ์ผ, d_E: ๋ฉ์นด ์ถ๋ฐ์ผ
a_Q: ๋ํ ๋์ฐฉ์ผ, d_Q: ๋ํ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_K - a_K + 1 = 7
d_D - a_D + 1 = 4
d_A - a_A + 1 = 2
d_M - a_M + 1 = 3
d_E - a_E + 1 = 6
d_Q - a_Q + 1 = 5
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_K, d_D, d_A, d_M, d_E, d_Q) - min(a_K, a_D, a_A, a_M, a_E, a_Q) + 1 = 22
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[10, 16] โฉ [a_K, d_K] โ โ
{7, 8} โฉ [a_Q, d_Q] โ โ
์งํญํธ์ด ์๋ ๋์:
(M โ Q), (M โ A), (K โ M), (E โ K), (A โ E), (D โ E), (D โ Q), (D โ M)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-4์ผ์ฐจ: 4์ผ๊ฐ ๋๋ฐ์ด ๋ฐฉ๋ฌธ.
4์ผ์ฐจ: ๋๋ฐ์ด์์ ๋ํ๋ก ๋นํ.
4-8์ผ์ฐจ: 5์ผ๊ฐ ๋ํ ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ๋ํ์์ ๋ฌดํ๋ผํฌ๋ก ๋นํ.
8-10์ผ์ฐจ: 3์ผ๊ฐ ๋ฌดํ๋ผํฌ ๋ฐฉ๋ฌธ.
10์ผ์ฐจ: ๋ฌดํ๋ผํฌ์์ ์ฟ ์จ์ดํธ๋ก ๋นํ.
10-16์ผ์ฐจ: 7์ผ๊ฐ ์ฟ ์จ์ดํธ ๋ฐฉ๋ฌธ.
16์ผ์ฐจ: ์ฟ ์จ์ดํธ์์ ๋ฉ์นด๋ก ๋นํ.
16-21์ผ์ฐจ: 6์ผ๊ฐ ๋ฉ์นด ๋ฐฉ๋ฌธ.
21์ผ์ฐจ: ๋ฉ์นด์์ ์๋ด์ผ๋ก ๋นํ.
21-22์ผ์ฐจ: 2์ผ๊ฐ ์๋ด ๋ฐฉ๋ฌธ.
|
98
|
์์์
| 6
|
์ง์ ์์ฑ
|
์ด 23์ผ ๋์ ์์์ 6๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์ค๋ ์์ 3์ผ๊ฐ ์ฌํ์ ํ ๊ฒ์
๋๋ค. 7์ผ๊ฐ ๊ด์ ์ฐ๋ฅผ ๋ฐฉ๋ฌธํ ๊ฒ์
๋๋ค. ์๊ณค์์ 7์ผ์ ๋ณด๋ผ ๊ฒ์
๋๋ค. ์๊ณค์์ 17์ผ๊ณผ 22์ผ ์ฌ์ด์ ํ๊ต ๊ฑด์ค ๋ด์ฌ๋ฅผ ํ๊ธฐ๋ก ๊ณํ๋์ด ์์ต๋๋ค. 4์ผ ๋์์ ๋ค๋์ ์์ ๊ฒ์
๋๋ค. 2์ผ ๋์ ํํธ์์ ์๊ฐ์ ๋ณด๋ผ ๊ฒ์
๋๋ค. 14์ผ๊ณผ 15์ผ ์ฌ์ด์ ํํธ๋ฅผ ์ ๊น ๋ค๋ฅด๋ ค๊ณ ํฉ๋๋ค. 5์ผ๊ฐ ๋ค๋ฅดํญ์ ์์ ๊ฒ์
๋๋ค. ๋ค๋ฅดํญ์์ 2-4์ผ ์ฌ์ด์ ๋จธ๋ฌด๋ฅผ ๊ฒ๋ฅด๋ฅผ ์์ฝํด๋์์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๊ด์ ์ฐ์ ์ค๋ , ๊ด์ ์ฐ์ ์๊ณค, ๋ค๋๊ณผ ๊ด์ ์ฐ, ๋ค๋๊ณผ ์๊ณค, ํํธ์ ๋ค๋, ์ค๋ ๊ณผ ์๊ณค, ์ค๋ ๊ณผ ํํธ, ๋ค๋ฅดํญ๊ณผ ๊ด์ ์ฐ, ๋ค๋ฅดํญ๊ณผ ํํธ.
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 23์ผ ๋์ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ๋ค๋ฅดํญ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋ค๋ฅดํญ์์ ๊ด์ ์ฐ๋ก ๋นํ.
5-11์ผ์ฐจ: 7์ผ๊ฐ ๊ด์ ์ฐ ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ๊ด์ ์ฐ์์ ๋ค๋์ผ๋ก ๋นํ.
11-14์ผ์ฐจ: 4์ผ๊ฐ ๋ค๋ ๋ฐฉ๋ฌธ.
14์ผ์ฐจ: ๋ค๋์์ ๋คํธ๋ก ๋นํ.
14-15์ผ์ฐจ: 2์ผ๊ฐ ํํธ ๋ฐฉ๋ฌธ.
15์ผ์ฐจ: ํํธ์์ ์ค๋ ์ผ๋ก ๋นํ.
15-17์ผ์ฐจ: 3์ผ๊ฐ ์ค๋ ๋ฐฉ๋ฌธ.
17์ผ์ฐจ: ์ค๋ ์์ ์๊ณค์ผ๋ก ๋นํ.
17-23์ผ์ฐจ: 7์ผ๊ฐ ์๊ณค ๋ฐฉ๋ฌธ.
|
You plan to visit 6 cities in Asia for a total of 23 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You'll be in Sylhet for 3 days. You'll be in Guangzhou for 7 days. You'll be in Yangon for 7 days. You'll be in Yangon to meet your sister between the 17th and 22nd. You will be in Dhahran for 4 days. You'll be in Thimphu for 2 days. You plan to make a brief stop in Thimphu between the 14th and the 15th. You're be in Darkhan for 5 days. You've booked a guesthouse in Darkhan to stay between 2-4 days.
Here are the cities that have direct flights: Guangzhou and Sylhet, Guangzhou and Yangon, Dhahran and Guangzhou, Dhahran and Yangon, Thimphu and Dhahran, Sylhet and Yangon, Sylhet and Thimphu, Darkhan and Guangzhou, Darkhan and Thimphu.
Plan your trip to visit six cities in 23 days with direct flights.
|
Days 1-5: Visit Darkhan for 5 days.
Day 5: Fly from Darkhan to Guangzhou.
Days 5-11: Visit Guangzhou for 7 days.
Day 11: Fly from Guangzhou to Darkhan.
Days 11-14: Visit Dhahran for 4 days.
Day 14: Fly from Dhahran to Thimphu.
Days 14-15: Visit Thimphu for 2 days.
Day 15: Fly from Thimphu to Sylhet.
Days 15-17: Visit Sylhet for 3 days.
Day 17: Fly from Sylhet to Yangon.
Days 17-23: Visit Yangon for 7 days.
|
๋ณ์ ์ ์:
S: ์ค๋ , G: ๊ด์ ์ฐ, Y: ์๊ณค, D: ๋ค๋, T: ํํธ, H: ๋ค๋ฅดํญ
a_S: ์ค๋ ๋์ฐฉ์ผ, d_S: ์ค๋ ์ถ๋ฐ์ผ
a_G: ๊ด์ ์ฐ ๋์ฐฉ์ผ, d_G: ๊ด์ ์ฐ ์ถ๋ฐ์ผ
a_Y: ์๊ณค ๋์ฐฉ์ผ, d_Y: ์๊ณค ์ถ๋ฐ์ผ
a_D: ๋ค๋ ๋์ฐฉ์ผ, d_D: ๋ค๋ ์ถ๋ฐ์ผ
a_T: ํํธ ๋์ฐฉ์ผ, d_T: ํํธ ์ถ๋ฐ์ผ
a_H: ๋ค๋ฅดํญ ๋์ฐฉ์ผ, d_H: ๋ค๋ฅดํญ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_S - a_S + 1 = 3
d_G - a_G + 1 = 7
d_Y - a_Y + 1 = 7
d_D - a_D + 1 = 4
d_T - a_T + 1 = 2
d_H - a_H + 1 = 5
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_S, d_G, d_Y, d_D, d_T, d_H) - min(a_S, a_G, a_Y, a_D, a_T, a_H) + 1 = 23
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[17, 22] โฉ [a_Y, d_Y] โ โ
{14, 15} โฉ [a_T, d_T] โ โ
[2, 4] โฉ [a_H, d_H] โ โ
์งํญํธ์ด ์๋ ๋์:
(G โ S), (G โ Y), (D โ G), (D โ Y), (T โ D), (S โ Y), (S โ T), (H โ G), (H โ T)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-5์ผ์ฐจ: 5์ผ๊ฐ ๋ค๋ฅดํญ ๋ฐฉ๋ฌธ.
5์ผ์ฐจ: ๋ค๋ฅดํญ์์ ๊ด์ ์ฐ๋ก ๋นํ.
5-11์ผ์ฐจ: 7์ผ๊ฐ ๊ด์ ์ฐ ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ๊ด์ ์ฐ์์ ๋ค๋์ผ๋ก ๋นํ.
11-14์ผ์ฐจ: 4์ผ๊ฐ ๋ค๋ ๋ฐฉ๋ฌธ.
14์ผ์ฐจ: ๋ค๋์์ ๋คํธ๋ก ๋นํ.
14-15์ผ์ฐจ: 2์ผ๊ฐ ํํธ ๋ฐฉ๋ฌธ.
15์ผ์ฐจ: ํํธ์์ ์ค๋ ์ผ๋ก ๋นํ.
15-17์ผ์ฐจ: 3์ผ๊ฐ ์ค๋ ๋ฐฉ๋ฌธ.
17์ผ์ฐจ: ์ค๋ ์์ ์๊ณค์ผ๋ก ๋นํ.
17-23์ผ์ฐจ: 7์ผ๊ฐ ์๊ณค ๋ฐฉ๋ฌธ.
|
99
|
์์์
| 6
|
์ง์ ์์ฑ
|
์ด 25์ผ ๋์ ์์์ 6๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์ฑ๊ฐํฌ๋ฅด์์ 6์ผ์ ๋ณด๋ด๋ ค๊ณ ํฉ๋๋ค. 3์ผ๊ฐ ์ฝ๋กฌ๋ณด์ ์๊ณ ์ถ์ต๋๋ค. ๋ง๋ ์์๋ 4์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. ์ฝํํค๋๋ฐ๋ฃจ์์ 6์ผ๊ฐ ๋จธ๋ฌด๋ฅด๋ ค ํฉ๋๋ค. ์๊ทธ๋ผ์์ 6์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. ๋ฐ๋ฅ์์ 5์ผ์ ๋ณด๋ด๊ณ ์ ํฉ๋๋ค. ๋จธ๋ฌด๋ ์ผ์๊ฐ ๊ฐ์ฅ ์งง์ ๋์๋ฅผ ๋๋ฒ์งธ ์ฌ์ ์ง๋ก ์ผ๊ณ ์ถ์ต๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ์ฝ๋กฌ๋ณด์ ์๊ทธ๋ผ, ์ฑ๊ฐํฌ๋ฅด์ ์ฝํํค๋๋ฐ๋ฃจ, ๋ฐ๋ฅ๊ณผ ์ฝํํค๋๋ฐ๋ฃจ, ์ฝ๋กฌ๋ณด์ ๋ง๋ , ๋ฐ๋ฅ๊ณผ ๋ง๋ .
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 25์ผ ๋์ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-6์ผ์ฐจ: 6์ผ๊ฐ ์๊ทธ๋ผ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์๊ทธ๋ผ์์ ์ฝ๋กฌ๋ณด๋ก ๋นํ.
6-8์ผ์ฐจ: 3์ผ๊ฐ ์ฝ๋กฌ๋ณด ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ์ฝ๋กฌ๋ณด์์ ๋ง๋ ๋ก ๋นํ.
8-11์ผ์ฐจ: 4์ผ๊ฐ ๋ง๋ ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ๋ง๋ ์์ ๋ฐ๋ฅ์ผ๋ก ๋นํ.
11-15์ผ์ฐจ: 5์ผ๊ฐ ๋ฐ๋ฅ ๋ฐฉ๋ฌธ.
15์ผ์ฐจ: ๋ฐ๋ฅ์์ ์ฝํํค๋๋ฐ๋ฃจ๋ก ๋นํ.
15-20์ผ์ฐจ: 6์ผ๊ฐ ์ฝํํค๋๋ฐ๋ฃจ ๋ฐฉ๋ฌธ.
20์ผ์ฐจ: ์ฝํํค๋๋ฐ๋ฃจ์์ ์ฑ๊ฐํฌ๋ฅด๋ก ๋นํ.
20-25์ผ์ฐจ: 6์ผ๊ฐ ์ฑ๊ฐํฌ๋ฅด ๋ฐฉ๋ฌธ.
|
You plan to visit 6 cities in Asia for a total of 25 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You want to spend 6 days in Singapore. You want to be in Colombo for 3 days. You want to spend 4 days in Male. You want to spend 6 days in Kota Kinabalu. You want to spend 6 days in Agra. You want to spend 5 days in Bandung. You want to make the city where you will stay the shortest your second destination.
Here are the cities that have direct flights: Colombo and Agra, Singapore and Kota Kinabalu, Bandung and Kota Kinabalu, Colombo and Male, Bandung and Male.
Plan a trip to visit six cities in 25 days using direct flights.
|
Days 1-6: Visit Agra for 6 days.
Day 6: Fly from Agra to Colombo.
Days 6-8: Visit Colombo for 3 days.
Day 8: Fly from Colombo to Male.
Days 8-11: Visit Male for 4 days.
Day 11: Fly from Male to Bandung.
Days 11-15: Visit Bandung for 5 days.
Day 15: Fly from Bandung to Kota Kinabalu.
Days 15-20: Visit Kota Kinabalu for 6 days.
Day 20: Fly from Kota Kinabalu to Singapore.
Days 20-25: Visit Singapore for 6 days.
|
๋ณ์ ์ ์:
S: ์ฑ๊ฐํฌ๋ฅด, C: ์ฝ๋กฌ๋ณด, M: ๋ง๋ , K: ์ฝํํค๋๋ฐ๋ฃจ, A: ์๊ทธ๋ผ, B: ๋ฐ๋ฅ
a_S: ์ฑ๊ฐํฌ๋ฅด ๋์ฐฉ์ผ, d_S: ์ฑ๊ฐํฌ๋ฅด ์ถ๋ฐ์ผ
a_C: ์ฝ๋กฌ๋ณด ๋์ฐฉ์ผ, d_C: ์ฝ๋กฌ๋ณด ์ถ๋ฐ์ผ
a_M: ๋ง๋ ๋์ฐฉ์ผ, d_M: ๋ง๋ ์ถ๋ฐ์ผ
a_K: ์ฝํํค๋๋ฐ๋ฃจ ๋์ฐฉ์ผ, d_K: ์ฝํํค๋๋ฐ๋ฃจ ์ถ๋ฐ์ผ
a_A: ์๊ทธ๋ผ ๋์ฐฉ์ผ, d_A: ์๊ทธ๋ผ ์ถ๋ฐ์ผ
a_B: ๋ฐ๋ฅ ๋์ฐฉ์ผ, d_B: ๋ฐ๋ฅ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_S - a_S + 1 = 6
d_C - a_C + 1 = 3
d_M - a_M + 1 = 4
d_K - a_K + 1 = 6
d_A - a_A + 1 = 6
d_B - a_B + 1 = 5
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_S, d_C, d_M, d_K, d_A, d_B) - min(a_S, a_C, a_M, a_K, a_A, a_B) + 1 = 25
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
a_C = min(a_S, a_C, a_M, a_K, a_A, a_B) + 1
์งํญํธ์ด ์๋ ๋์:
(C โ A), (S โ K), (B โ K), (C โ M), (B โ M)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-6์ผ์ฐจ: 6์ผ๊ฐ ์๊ทธ๋ผ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ์๊ทธ๋ผ์์ ์ฝ๋กฌ๋ณด๋ก ๋นํ.
6-8์ผ์ฐจ: 3์ผ๊ฐ ์ฝ๋กฌ๋ณด ๋ฐฉ๋ฌธ.
8์ผ์ฐจ: ์ฝ๋กฌ๋ณด์์ ๋ง๋ ๋ก ๋นํ.
8-11์ผ์ฐจ: 4์ผ๊ฐ ๋ง๋ ๋ฐฉ๋ฌธ.
11์ผ์ฐจ: ๋ง๋ ์์ ๋ฐ๋ฅ์ผ๋ก ๋นํ.
11-15์ผ์ฐจ: 5์ผ๊ฐ ๋ฐ๋ฅ ๋ฐฉ๋ฌธ.
15์ผ์ฐจ: ๋ฐ๋ฅ์์ ์ฝํํค๋๋ฐ๋ฃจ๋ก ๋นํ.
15-20์ผ์ฐจ: 6์ผ๊ฐ ์ฝํํค๋๋ฐ๋ฃจ ๋ฐฉ๋ฌธ.
20์ผ์ฐจ: ์ฝํํค๋๋ฐ๋ฃจ์์ ์ฑ๊ฐํฌ๋ฅด๋ก ๋นํ.
20-25์ผ์ฐจ: 6์ผ๊ฐ ์ฑ๊ฐํฌ๋ฅด ๋ฐฉ๋ฌธ.
|
100
|
์์์
| 6
|
์ง์ ์์ฑ
|
์ด 22์ผ ๋์ ์์์ 6๊ฐ ๋์๋ฅผ ๋ฐฉ๋ฌธํ ๊ณํ์
๋๋ค. ๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ์์ ๊ฐ๋ฅํ๋ฉฐ, ํญ๊ณตํธ์ ๊ฐ ๋์์ ๋จธ๋ฌด๋ฅด๋ ์ผ์ ์ ์ํฅ์ ๋ผ์น์ง ์์ต๋๋ค. ์๋ง์์ 6์ผ์ ๋จธ๋ฌด๋ฅด๊ณ ์ ํฉ๋๋ค. 16์ผ๊ณผ 21์ผ ์ฌ์ด์ ์๋ง์์ ํจ๊ป ๊ด๊ด์ ํ ์ฌํ ๋ฉ์ดํธ๋ฅผ ๊ตฌํ์ต๋๋ค. ๋ฒ ์ด๋ฃจํธ์์ 4์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค. ์๋ฃจ์ด๋ ์์ 5์ผ์ ๋ณด๋ผ ์์ ์
๋๋ค. 7์ผ๊ฐ์ ๋ฐ๊ทธ๋ค๋์ ์์ ์์ ์
๋๋ค. 12์ผ์ ๋ฐ๊ทธ๋ค๋์์ ๋ค๋ฅธ ๋์๋ก ์ด๋ํ๊ณ ์ ํฉ๋๋ค. 3์ผ๊ฐ ๋ค๋ง์ค์ฟ ์ค์ ์์ ์์ ์
๋๋ค. 2์ผ๊ณผ 3์ผ ์ฌ์ด์ ๋ค๋ง์ค์ฟ ์ค์ ์๋ ์ด๋ ๋์ฌ๊ด์ ๋ฐฉ๋ฌธํด์ผ ํฉ๋๋ค. ์ฟ ์จ์ดํธ์์๋ 2์ผ์ ๋ณด๋ผ ๊ฒ์
๋๋ค.
์งํญํธ์ด ์๋ ๋์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ๋ฐ๊ทธ๋ค๋์ ์ฟ ์์ดํธ, ๋ฒ ์ด๋ฃจํธ์ ๋ฐ๊ทธ๋ค๋, ๋ฒ ์ด๋ฃจํธ์ ์๋ง, ๋ฒ ์ด๋ฃจํธ์ ์ฟ ์จ์ดํธ, ์๋ฃจ์ด๋ ๊ณผ ๋ฐ๊ทธ๋ค๋, ์ฟ ์จ์ดํธ์ ์๋ง, ๋ค๋ง์ค์ฟ ์ค์ ๋ฒ ์ด๋ฃจํธ, ๋ค๋ง์ค์ฟ ์ค์ ์๋ฃจ์ด๋ , ์๋ง๊ณผ ์๋ฃจ์ด๋ .
์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ 22์ผ ๋์ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋ค๋ง์ค์ฟ ์ค ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋ค๋ง์ค์ฟ ์ค์์ ๋ฒ ์ด๋ฃจํธ๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ๋ฒ ์ด๋ฃจํธ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋ฒ ์ด๋ฃจํธ์์ ๋ฐ๊ทธ๋ค๋๋ก ๋นํ.
6-12์ผ์ฐจ: 7์ผ๊ฐ ๋ฐ๊ทธ๋ค๋ ๋ฐฉ๋ฌธ.
12์ผ์ฐจ: ๋ฐ๊ทธ๋ค๋์์ ์์์ด๋ ์ผ๋ก ๋นํ.
12-16์ผ์ฐจ: 5์ผ๊ฐ ์๋ฃจ์ด๋ ๋ฐฉ๋ฌธ.
16์ผ์ฐจ: ์๋ฃจ์ด๋ ์์ ์๋ง์ผ๋ก ๋นํ.
16-21์ผ์ฐจ: 6์ผ๊ฐ ์๋ง ๋ฐฉ๋ฌธ.
21์ผ์ฐจ: ์๋ง์์ ์ฟ ์จ์ดํธ๋ก ๋นํ.
21-22์ผ์ฐจ: 2์ผ๊ฐ ์ฟ ์จ์ดํธ ๋ฐฉ๋ฌธ.
|
You plan to visit 6 cities in Asia for a total of 22 days. You will only take direct flights between cities. Travel between cities is possible within a day, and flights do not affect the itinerary for staying in each city. You plan to spend 6 days in Amman. You found a travel mate to explore Amman together between the 16th and 21st. You want to spend 4 days in Beirut. You are planning to spend 5 days in Jerusalem. You will be in Baghdad for 7 days. You want to travel from Baghdad to another city on the 12th. You will be in Damascus for 3 days. Between days 2 and 3, you need to visit the Iranian Embassy in Damascus. You will spend 2 days in Kuwait.
Here are the cities that have direct flights: Baghdad and Kuwait, Beirut and Baghdad, Beirut and Amman, Beirut and Kuwait, Jerusalem and Baghdad, Kuwait and Amman, Damascus and Beirut, Damascus and Jerusalem, Amman and Jerusalem.
Plan a trip to visit six cities in 22 days with direct flights.
|
Days 1-3: Visit Damascus for 3 days.
Day 3: Fly from Damascus to Beirut.
Days 3-6: Visit Beirut for 4 days.
Day 6: Fly from Beirut to Baghdad.
Days 6-12: Visit Baghdad for 7 days.
Day 12: Fly from Baghdad to Jerusalem.
Days 12-16: Visit Jerusalem for 5 days.
Day 16: Fly from Jerusalem to Amman.
Days 16-21: Visit Amman for 6 days.
Day 21: Fly from Amman to Kuwait.
Days 21-22: Visit Kuwait for 2 days.
|
๋ณ์ ์ ์:
A: ์๋ง, B: ๋ฒ ์ด๋ฃจํธ, J: ์๋ฃจ์ด๋ , G: ๋ฐ๊ทธ๋ค๋, D: ๋ค๋ง์ค์ฟ ์ค, K: ์ฟ ์จ์ดํธ
a_A: ์๋ง ๋์ฐฉ์ผ, d_A: ์๋ง ์ถ๋ฐ์ผ
a_B: ๋ฒ ์ด๋ฃจํธ ๋์ฐฉ์ผ, d_B: ๋ฒ ์ด๋ฃจํธ ์ถ๋ฐ์ผ
a_J: ์๋ฃจ์ด๋ ๋์ฐฉ์ผ, d_J: ์๋ฃจ์ด๋ ์ถ๋ฐ์ผ
a_G: ๋ฐ๊ทธ๋ค๋ ๋์ฐฉ์ผ, d_G: ๋ฐ๊ทธ๋ค๋ ์ถ๋ฐ์ผ
a_D: ๋ค๋ง์ค์ฟ ์ค ๋์ฐฉ์ผ, d_D: ๋ค๋ง์ค์ฟ ์ค ์ถ๋ฐ์ผ
a_K: ์ฟ ์จ์ดํธ ๋์ฐฉ์ผ, d_K: ์ฟ ์จ์ดํธ ์ถ๋ฐ์ผ
์ ์ฝ ์กฐ๊ฑด:
๊ฐ ๋์์์์ ์ฒด๋ฅ ๊ธฐ๊ฐ:
d_A - a_A + 1 = 6
d_B - a_B + 1 = 4
d_J - a_J + 1 = 5
d_G - a_G + 1 = 7
d_D - a_D + 1 = 3
d_K - a_K + 1 = 2
์ ์ฒด ์ฌํ ๊ธฐ๊ฐ:
max(d_A, d_B, d_J, d_G, d_D, d_K) - min(a_A, a_B, a_J, a_G, a_D, a_K) + 1 = 22
์ธ๋ถ ์ ์ฝ ์กฐ๊ฑด:
[16, 21] โฉ [a_A, d_A] โ โ
d_G = 12
{2, 3} โฉ [a_D, d_D] โ โ
์งํญํธ์ด ์๋ ๋์:
(G โ K), (B โ G), (B โ A), (B โ K), (J โ G), (K โ A), (D โ B), (D โ J), (A โ J)
๋์ ๊ฐ์ ์ด๋ํ ๋๋ ์งํญ ํญ๊ณตํธ๋ง ์ด์ฉํฉ๋๋ค. ๋์ ๊ฐ ์ด๋์ ํ๋ฃจ ๋ด์ ์ด๋ฃจ์ด์ง๋ฉฐ ์ด๋ ์๊ฐ์ด ์ฒด๋ฅ ๊ธฐ๊ฐ์ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค. ์งํญ ํญ๊ณตํธ์ ์ด์ฉํ์ฌ ์ฌ์ฏ ๋์๋ฅผ ๋ฐฉ๋ฌธํ๋ ์ฌํ ๊ณํ์ ์ธ์๋ณด์ธ์.
|
1-3์ผ์ฐจ: 3์ผ๊ฐ ๋ค๋ง์ค์ฟ ์ค ๋ฐฉ๋ฌธ.
3์ผ์ฐจ: ๋ค๋ง์ค์ฟ ์ค์์ ๋ฒ ์ด๋ฃจํธ๋ก ๋นํ.
3-6์ผ์ฐจ: 4์ผ๊ฐ ๋ฒ ์ด๋ฃจํธ ๋ฐฉ๋ฌธ.
6์ผ์ฐจ: ๋ฒ ์ด๋ฃจํธ์์ ๋ฐ๊ทธ๋ค๋๋ก ๋นํ.
6-12์ผ์ฐจ: 7์ผ๊ฐ ๋ฐ๊ทธ๋ค๋ ๋ฐฉ๋ฌธ.
12์ผ์ฐจ: ๋ฐ๊ทธ๋ค๋์์ ์์์ด๋ ์ผ๋ก ๋นํ.
12-16์ผ์ฐจ: 5์ผ๊ฐ ์๋ฃจ์ด๋ ๋ฐฉ๋ฌธ.
16์ผ์ฐจ: ์๋ฃจ์ด๋ ์์ ์๋ง์ผ๋ก ๋นํ.
16-21์ผ์ฐจ: 6์ผ๊ฐ ์๋ง ๋ฐฉ๋ฌธ.
21์ผ์ฐจ: ์๋ง์์ ์ฟ ์จ์ดํธ๋ก ๋นํ.
21-22์ผ์ฐจ: 2์ผ๊ฐ ์ฟ ์จ์ดํธ ๋ฐฉ๋ฌธ.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.