Skip to content

Commit

Permalink
Merge pull request #143 from AlgoLeadMe/36-pknujsp
Browse files Browse the repository at this point in the history
36 pknujsp
  • Loading branch information
pknujsp authored Mar 4, 2024
2 parents 323ab91 + 733bc21 commit 5749510
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 13 deletions.
43 changes: 43 additions & 0 deletions pknujsp/BFS/34-์ด๋ถ„ ๊ทธ๋ž˜ํ”„.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from sys import *
from collections import *


def bfs(start):
q = deque([start])
groups[start] = 1

while q:
curr = q.popleft()
visited[curr] = True

for adj in graph[curr]:
if visited[adj]:
continue

if not groups[adj]:
groups[adj] = -groups[curr]
q.append(adj)
elif groups[adj] == groups[curr]:
return False
return True


for _ in range(int(stdin.readline())):
V, E = map(int, stdin.readline().split())
graph = [[] for i in range(V + 1)]

for _ in range(E):
a, b = map(int, stdin.readline().split())
graph[a].append(b)
graph[b].append(a)

groups = [0] * (V + 1)
visited = [False] * (V + 1)
result = None

for i in range(1, V + 1):
if groups[i] == 0 and not bfs(i):
result = 'NO'
break

print('YES' if not result else result)
30 changes: 17 additions & 13 deletions pknujsp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,20 @@
| 17์ฐจ์‹œ | 2023.11.10 | ์Šคํƒ | [์ง์ง€์–ด ์ œ๊ฑฐํ•˜๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/12973) | [#54](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/54) |
| 18์ฐจ์‹œ | 2023.11.13 | ๊ตฌํ˜„ | [ํ‚คํŒจ๋“œ ๋ˆ„๋ฅด๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/67256) | [#60](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/60) |
| 19์ฐจ์‹œ | 2023.11.17 | ๊ตฌํ˜„ | [์‹คํŒจ์œจ](https://school.programmers.co.kr/learn/courses/30/lessons/42889) | [#64](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/64) |
| 20์ฐจ์‹œ | 2023.11.20 | ๋ฌธ์ž์—ด | [์˜น์•Œ์ด (2)](https://school.programmers.co.kr/learn/courses/30/lessons/133499) | [#70](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/70) |
| 21์ฐจ์‹œ | 2023.11.23 | ๋งต | [์˜์ƒ](https://school.programmers.co.kr/learn/courses/30/lessons/42578) | [#73](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/73) |
| 22์ฐจ์‹œ | 2023.11.26 | ๊ทธ๋ฆฌ๋”” | [๊ตฌ๋ช…๋ณดํŠธ](https://school.programmers.co.kr/learn/courses/30/lessons/42885) | [#79](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/79) |
| 23์ฐจ์‹œ | 2023.11.30 | ๋‹ค์ต์ŠคํŠธ๋ผ | [์ง€๋ฆ„๊ธธ](https://www.acmicpc.net/problem/1446) | [#82](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/82) |
| 24์ฐจ์‹œ | 2023.12.23 | ํ”Œ๋กœ์ด๋“œ์™€์…œ | [์ˆœ์œ„](https://school.programmers.co.kr/learn/courses/30/lessons/49191) | [#88](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/88) |
| 25์ฐจ์‹œ | 2023.12.27 | BFS | [ํ† ๋งˆํ† ](https://www.acmicpc.net/problem/7569) | [#93](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/93) |
| 26์ฐจ์‹œ | 2024.01.02 | ์ด์ง„ํƒ์ƒ‰ | [์ž…๊ตญ์‹ฌ์‚ฌ](https://school.programmers.co.kr/learn/courses/30/lessons/43238) | [#98](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/98) |
| 27์ฐจ์‹œ | 2024.01.05 | DP | [N์œผ๋กœ ํ‘œํ˜„](https://school.programmers.co.kr/learn/courses/30/lessons/42895) | [#101](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/101) |
| 28์ฐจ์‹œ | 2024.01.16 | ๊ทธ๋ฆฌ๋”” | [๋ฌด์ง€์˜ ๋จน๋ฐฉ ๋ผ์ด๋ธŒ](https://school.programmers.co.kr/learn/courses/30/lessons/42891) | [#110](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/110) |
| 29์ฐจ์‹œ | 2024.01.18 | DFS, UNION-FIND | [์ˆœ์—ด ์‚ฌ์ดํด](https://www.acmicpc.net/problem/10451) | [#112](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/112) |
| 30์ฐจ์‹œ | 2024.01.23 | DP | [ABBC](https://www.acmicpc.net/problem/25381) | [#119](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/119) |
| 31์ฐจ์‹œ | 2024.01.30 | SORT | [๋ฉ€ํ‹ฐ๋ฒ„์Šค โ…ก](https://www.acmicpc.net/problem/18869) | [#123](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/123) |
| 32์ฐจ์‹œ | 2024.02.04 | BFS | [์ˆจ๋ฐ”๊ผญ์งˆ 3](https://www.acmicpc.net/problem/13549) | [#127](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/127) |
| 20์ฐจ์‹œ | 2023.11.20 | ๋ฌธ์ž์—ด | [์˜น์•Œ์ด (2)](https://school.programmers.co.kr/learn/courses/30/lessons/133499) | [#70](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/70) |
| 21์ฐจ์‹œ | 2023.11.23 | ๋งต | [์˜์ƒ](https://school.programmers.co.kr/learn/courses/30/lessons/42578) | [#73](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/73) |
| 22์ฐจ์‹œ | 2023.11.26 | ๊ทธ๋ฆฌ๋”” | [๊ตฌ๋ช…๋ณดํŠธ](https://school.programmers.co.kr/learn/courses/30/lessons/42885) | [#79](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/79) |
| 23์ฐจ์‹œ | 2023.11.30 | ๋‹ค์ต์ŠคํŠธ๋ผ | [์ง€๋ฆ„๊ธธ](https://www.acmicpc.net/problem/1446) | [#82](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/82) |
| 24์ฐจ์‹œ | 2023.12.23 | ํ”Œ๋กœ์ด๋“œ์™€์…œ | [์ˆœ์œ„](https://school.programmers.co.kr/learn/courses/30/lessons/49191) | [#88](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/88) |
| 25์ฐจ์‹œ | 2023.12.27 | BFS | [ํ† ๋งˆํ† ](https://www.acmicpc.net/problem/7569) | [#93](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/93) |
| 26์ฐจ์‹œ | 2024.01.02 | ์ด์ง„ํƒ์ƒ‰ | [์ž…๊ตญ์‹ฌ์‚ฌ](https://school.programmers.co.kr/learn/courses/30/lessons/43238) | [#98](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/98) |
| 27์ฐจ์‹œ | 2024.01.05 | DP | [N์œผ๋กœ ํ‘œํ˜„](https://school.programmers.co.kr/learn/courses/30/lessons/42895) | [#101](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/101) |
| 28์ฐจ์‹œ | 2024.01.16 | ๊ทธ๋ฆฌ๋”” | [๋ฌด์ง€์˜ ๋จน๋ฐฉ ๋ผ์ด๋ธŒ](https://school.programmers.co.kr/learn/courses/30/lessons/42891) | [#110](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/110) |
| 29์ฐจ์‹œ | 2024.01.18 | DFS, UNION-FIND | [์ˆœ์—ด ์‚ฌ์ดํด](https://www.acmicpc.net/problem/10451) | [#112](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/112) |
| 30์ฐจ์‹œ | 2024.01.23 | DP | [ABBC](https://www.acmicpc.net/problem/25381) | [#119](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/119) |
| 31์ฐจ์‹œ | 2024.01.30 | SORT | [๋ฉ€ํ‹ฐ๋ฒ„์Šค โ…ก](https://www.acmicpc.net/problem/18869) | [#123](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/123) |
| 32์ฐจ์‹œ | 2024.02.04 | BFS | [์ˆจ๋ฐ”๊ผญ์งˆ 3](https://www.acmicpc.net/problem/13549) | [#127](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/127) |
| 33์ฐจ์‹œ | 2024.02.06 | ํ | [์ฒ ๋กœ](https://www.acmicpc.net/problem/13334) | [#132](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/132) |
| 34์ฐจ์‹œ | 2024.02.12 | BFS | [์ด๋ถ„ ๊ทธ๋ž˜ํ”„](https://www.acmicpc.net/problem/1707) | [#135](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/135) |
| 35์ฐจ์‹œ | 2024.02.18 | ๊ทธ๋ฆฌ๋”” | [์„ ๋ฌผํ• ์ธ](https://www.acmicpc.net/problem/25947) | [#137](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/137) |
| 36์ฐจ์‹œ | 2024.02.21 | ์ด์ง„ํƒ์ƒ‰ | [ํœด๊ฒŒ์†Œ ์„ธ์šฐ๊ธฐ](https://www.acmicpc.net/problem/1477) | [#143](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/143) |
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from sys import *

n, budget, max_sales = map(int, stdin.readline().split())
gifts = sorted(list(map(int, stdin.readline().split())))

min_price_gift = max_price_gift = 0
prices = 0
sales = 0

for sale_gift in range(max_sales):
prices += gifts[sale_gift] // 2
max_price_gift += 1

if prices > budget:
print(sale_gift)
exit()

sales = max_price_gift - min_price_gift
while max_price_gift < n:
if sales < max_sales or max_sales == 0:
if max_sales == 0:
prices += gifts[max_price_gift]
else:
prices += gifts[max_price_gift] // 2

if prices > budget:
break

max_price_gift += 1
sales += 1
else:
prices += gifts[min_price_gift] // 2
min_price_gift += 1
sales -= 1

print(max_price_gift)
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
N, M, L = map(int, input().split())
array = list(map(int, input().split()))
array.sort()

left = 1
right = L - 1

min_max_distance = right

while left <= right:
max_distance = (left + right) // 2
extra_added = 0
last_installed_x = 0

for installed_x in array:
if installed_x - last_installed_x > max_distance:
extra_added += (installed_x - last_installed_x - 1) // max_distance

last_installed_x = installed_x

if L - last_installed_x > max_distance:
extra_added += (L - last_installed_x - 1) // max_distance

if extra_added > M:
left = max_distance + 1
else:
right = max_distance - 1

print(left)

28 changes: 28 additions & 0 deletions pknujsp/ํ/33-์ฒ ๋กœ.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from sys import *
from heapq import *

points = []

for _ in range(int(stdin.readline().strip())):
h, o = map(int, stdin.readline().strip().split())
points.append([min(h, o), max(h, o)])

points.sort(key=lambda x: x[1])
D = int(stdin.readline().strip())

max_users = 0
start_points_list = []

for start, destination in points:
if start + D < destination:
continue
heappush(start_points_list, start)

while start_points_list:
if start_points_list[0] + D >= destination:
break
heappop(start_points_list)

max_users = max(max_users, len(start_points_list))

print(max_users)

0 comments on commit 5749510

Please sign in to comment.