Skip to content

Commit

Permalink
Merge branch 'main' into 16-wkdghdwns199
Browse files Browse the repository at this point in the history
  • Loading branch information
wkdghdwns199 authored Mar 27, 2024
2 parents 491ab3e + 18146fb commit 62f5587
Show file tree
Hide file tree
Showing 15 changed files with 343 additions and 1 deletion.
1 change: 1 addition & 0 deletions alstjr7437/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
| 13์ฐจ์‹œ | 2024.02.29 | DP | <a href="https://www.acmicpc.net/problem/10844">์‰ฌ์šด ๊ณ„๋‹จ ์ˆ˜</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/42 |
| 14์ฐจ์‹œ | 2024.03.03 | ๋ธŒ๋ฃจํŠธํฌ์Šค | <a href="https://www.acmicpc.net/problem/18111">๋งˆ์ธํฌ๋ž˜ํ”„ํŠธ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/48 |
| 15์ฐจ์‹œ | 2024.03.09 | ์šฐ์„ ์ˆœ์œ„ ํ | <a href="https://www.acmicpc.net/problem/13975">ํŒŒ์ผ ํ•ฉ์น˜๊ธฐ3</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/53 |
| 16์ฐจ์‹œ | 2024.03.13 | ์ •๋ ฌ | <a href="https://www.acmicpc.net/problem/2170">์„  ๊ธ‹๊ธฐ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/57 |
3 changes: 3 additions & 0 deletions alstjr7437/์ •๋ ฌ/tempCodeRunnerFile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

# dohwaji[i][0] += 1000000000
# dohwaji[i][1] += 1000000000
27 changes: 27 additions & 0 deletions alstjr7437/์ •๋ ฌ/์„  ๊ธ‹๊ธฐ.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import sys
input = sys.stdin.readline

n = int(input())
dohwaji = [tuple(map(int,(input().split()))) for _ in range(n)]

# for i in range(len(dohwaji)):
# dohwaji[i][0] += 1000000000
# dohwaji[i][1] += 1000000000

dohwaji.sort()

line = dohwaji[0][1]
answer = dohwaji[0][1] - dohwaji[0][0]

for left, right in dohwaji[1:]:
if right <= line:
continue
elif line < left:
answer += right - left
line = right
elif line >= left and right > line:
answer += right - line
line = right
# print(answer)

print(answer)
1 change: 1 addition & 0 deletions fnzksxl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
| 9์ฐจ์‹œ | 2024-02-23 | ๊ทธ๋ž˜ํ”„ | [์ˆœ์œ„](https://school.programmers.co.kr/learn/courses/30/lessons/49191) | [#37](https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/37) |
| 10์ฐจ์‹œ | 2024-03-07 | ๊ตฌํ˜„ | [๋‚˜๋ฌด ์žฌํ…Œํฌ](https://www.acmicpc.net/problem/16235) | [#52](https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/52) |
| 11์ฐจ์‹œ | 2024-03-10 | ํˆฌํฌ์ธํ„ฐ | [๋ณด์„ ์‡ผํ•‘](https://school.programmers.co.kr/learn/courses/30/lessons/67258) | [#56](https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/56) |
| 12์ฐจ์‹œ | 2024-03-13 | ๋ฒจ๋งŒํฌ๋“œ | [ํƒ€์ž„๋จธ์‹ ](https://www.acmicpc.net/problem/11657) | [#](https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/58) |
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import sys

input = sys.stdin.readline


def func():
distances[1] = 0

for i in range(N):
for j in range(M):
cur_node, next_node, weight = edges[j]
if distances[cur_node] != float('inf') and distances[next_node] > distances[cur_node] + weight:
distances[next_node] = distances[cur_node] + weight
if i == N-1:
return False

return True


N, M = map(int, input().split())

edges = []
distances = [float('inf')] * (N+1)
q = []

for _ in range(M):
start, end, weight = map(int, input().split())
edges.append((start, end, weight))


if func():
for weight in distances[2:]:
if weight == float('inf'):
print(-1)
else:
print(weight)
else:
print(-1)
5 changes: 4 additions & 1 deletion wkdghdwns199/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@
| 11์ฐจ์‹œ | 2024.03.03 | ์Šคํƒ, ํ, ๋ฑ | <a href="https://www.acmicpc.net/problem/11866">์š”์„ธํ‘ธ์Šค ๋ฌธ์ œ 0</a> | <a href="">2024.03.03</a> |
| 12์ฐจ์‹œ | 2024.03.06 | DP | <a href="https://www.acmicpc.net/problem/1010">๋‹ค๋ฆฌ ๋†“๊ธฐ</a> | <a href="">2024.03.06</a> |
| 13์ฐจ์‹œ | 2024.03.09 | DP | <a href="https://www.acmicpc.net/problem/1932">์ •์ˆ˜ ์‚ผ๊ฐํ˜•</a> | <a href="">2024.03.09</a> |
| 16์ฐจ์‹œ | 2024.03.23 | ์กฐํ•ฉ๋ก  | <a href="https://www.acmicpc.net/problem/11050">์ดํ•ญ ๊ณ„์ˆ˜ 1 </a> | <a href="">2024.03.23</a> |
| 14์ฐจ์‹œ | 2024.03.13 | ์ง‘ํ•ฉ๊ณผ ๋งต | <a href="https://www.acmicpc.net/problem/20920">์˜๋‹จ์–ด ์•”๊ธฐ๋Š” ๊ดด๋กœ์›Œ</a> | <a href="">2024.03.13</a> |
| 15์ฐจ์‹œ | 2024.03.20 | ์šฐ์„ ์ˆœ์œ„ ํ | <a href="https://www.acmicpc.net/problem/11286">์ ˆ๋Œ“๊ฐ’ ํž™</a> | <a href="">2024.03.20</a> |
| 16์ฐจ์‹œ | 2024.03.23 | ์กฐํ•ฉ๋ก  | <a href="https://www.acmicpc.net/problem/11050">์ดํ•ญ ๊ณ„์ˆ˜ 1 </a> | <a href="">2024.03.23</a> |

77 changes: 77 additions & 0 deletions wkdghdwns199/๋ฆฌ๋ทฐํ’€์ด/ACM-11657.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
'''
๋ฌธ์ œ
N๊ฐœ์˜ ๋„์‹œ๊ฐ€ ์žˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ํ•œ ๋„์‹œ์—์„œ ์ถœ๋ฐœํ•˜์—ฌ ๋‹ค๋ฅธ ๋„์‹œ์— ๋„์ฐฉํ•˜๋Š” ๋ฒ„์Šค๊ฐ€ M๊ฐœ ์žˆ๋‹ค.
๊ฐ ๋ฒ„์Šค๋Š” A, B, C๋กœ ๋‚˜ํƒ€๋‚ผ ์ˆ˜ ์žˆ๋Š”๋ฐ, A๋Š” ์‹œ์ž‘๋„์‹œ, B๋Š” ๋„์ฐฉ๋„์‹œ, C๋Š” ๋ฒ„์Šค๋ฅผ ํƒ€๊ณ  ์ด๋™ํ•˜๋Š”๋ฐ ๊ฑธ๋ฆฌ๋Š” ์‹œ๊ฐ„์ด๋‹ค.
์‹œ๊ฐ„ C๊ฐ€ ์–‘์ˆ˜๊ฐ€ ์•„๋‹Œ ๊ฒฝ์šฐ๊ฐ€ ์žˆ๋‹ค. C = 0์ธ ๊ฒฝ์šฐ๋Š” ์ˆœ๊ฐ„ ์ด๋™์„ ํ•˜๋Š” ๊ฒฝ์šฐ, C < 0์ธ ๊ฒฝ์šฐ๋Š” ํƒ€์ž„๋จธ์‹ ์œผ๋กœ ์‹œ๊ฐ„์„ ๋˜๋Œ์•„๊ฐ€๋Š” ๊ฒฝ์šฐ์ด๋‹ค.
1๋ฒˆ ๋„์‹œ์—์„œ ์ถœ๋ฐœํ•ด์„œ ๋‚˜๋จธ์ง€ ๋„์‹œ๋กœ ๊ฐ€๋Š” ๊ฐ€์žฅ ๋น ๋ฅธ ์‹œ๊ฐ„์„ ๊ตฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค.
์ž…๋ ฅ
์ฒซ์งธ ์ค„์— ๋„์‹œ์˜ ๊ฐœ์ˆ˜ N (1 โ‰ค N โ‰ค 500), ๋ฒ„์Šค ๋…ธ์„ ์˜ ๊ฐœ์ˆ˜ M (1 โ‰ค M โ‰ค 6,000)์ด ์ฃผ์–ด์ง„๋‹ค.
๋‘˜์งธ ์ค„๋ถ€ํ„ฐ M๊ฐœ์˜ ์ค„์—๋Š” ๋ฒ„์Šค ๋…ธ์„ ์˜ ์ •๋ณด A, B, C (1 โ‰ค A, B โ‰ค N, -10,000 โ‰ค C โ‰ค 10,000)๊ฐ€ ์ฃผ์–ด์ง„๋‹ค.
์ถœ๋ ฅ
๋งŒ์•ฝ 1๋ฒˆ ๋„์‹œ์—์„œ ์ถœ๋ฐœํ•ด ์–ด๋–ค ๋„์‹œ๋กœ ๊ฐ€๋Š” ๊ณผ์ •์—์„œ ์‹œ๊ฐ„์„ ๋ฌดํ•œํžˆ ์˜ค๋ž˜ ์ „์œผ๋กœ ๋˜๋Œ๋ฆด ์ˆ˜ ์žˆ๋‹ค๋ฉด ์ฒซ์งธ ์ค„์— -1์„ ์ถœ๋ ฅํ•œ๋‹ค.
๊ทธ๋ ‡์ง€ ์•Š๋‹ค๋ฉด N-1๊ฐœ ์ค„์— ๊ฑธ์ณ ๊ฐ ์ค„์— 1๋ฒˆ ๋„์‹œ์—์„œ ์ถœ๋ฐœํ•ด 2๋ฒˆ ๋„์‹œ, 3๋ฒˆ ๋„์‹œ, ..., N๋ฒˆ ๋„์‹œ๋กœ ๊ฐ€๋Š” ๊ฐ€์žฅ ๋น ๋ฅธ ์‹œ๊ฐ„์„ ์ˆœ์„œ๋Œ€๋กœ ์ถœ๋ ฅํ•œ๋‹ค.
๋งŒ์•ฝ ํ•ด๋‹น ๋„์‹œ๋กœ ๊ฐ€๋Š” ๊ฒฝ๋กœ๊ฐ€ ์—†๋‹ค๋ฉด ๋Œ€์‹  -1์„ ์ถœ๋ ฅํ•œ๋‹ค.
์˜ˆ์ œ ์ž…๋ ฅ 1
3 4
1 2 4
1 3 3
2 3 -1
3 1 -2
์˜ˆ์ œ ์ถœ๋ ฅ 1
4
3
์˜ˆ์ œ ์ž…๋ ฅ 2
3 4
1 2 4
1 3 3
2 3 -4
3 1 -2
์˜ˆ์ œ ์ถœ๋ ฅ 2
-1
์˜ˆ์ œ ์ž…๋ ฅ 3
3 2
1 2 4
1 2 3
์˜ˆ์ œ ์ถœ๋ ฅ 3
3
-1
'''

import sys
input = sys.stdin.readline
INF = int(1e9)

def bellman_ford(start):
dist[start] = 0

for i in range(1,n+1):
for j in range(m):
now, next, cost = edges[j][0], edges[j][1], edges[j][2]
if dist[now] != INF and dist[next] > dist[now] + cost:
dist[next] = dist[now] + cost
if i == n :
return True
return False

n,m = map(int, input().split())
edges = []
dist = [INF] * (n+1)

for _ in range(m):
a,b,c = map(int, input().split())
edges.append((a,b,c))

negative_cycle = bellman_ford(1)
if negative_cycle :
print(-1)
else :
for i in range(2,n+1):
if dist[i] == INF:
print(-1)
else :
print(dist[i])
11 changes: 11 additions & 0 deletions wkdghdwns199/๋ฆฌ๋ทฐํ’€์ด/ACM-11659.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import sys
input = sys.stdin.readline
N,M = map(int, input().split())
num_list = list(map(int, input().split()))
accumulate_list = [0] * (N+1)
for i in range(N):
accumulate_list[i+1] = accumulate_list[i] + num_list[i]

for _ in range(M):
start, end = map(int, input().split())
print(accumulate_list[end] - accumulate_list[start-1])
17 changes: 17 additions & 0 deletions wkdghdwns199/๋ฆฌ๋ทฐํ’€์ด/ACM-13975.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import sys
from heapq import *
input = sys.stdin.readline
T = int(input())
for _ in range(T):
N = int(input())
chapters = list(map(int, input().split()))
time_list = []
min_time=0
for chapter in chapters :
heappush(time_list, chapter)
while len(time_list) > 1 :
temp =0
temp += heappop(time_list) + heappop(time_list)
heappush(time_list, temp)
min_time += temp
print(min_time)
42 changes: 42 additions & 0 deletions wkdghdwns199/๋ฆฌ๋ทฐํ’€์ด/ACM-14938.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import sys
from heapq import *
input = sys.stdin.readline

def dijkstra(graph, start):
length = [float('inf') for _ in graph]
length[start] = 0
queue = []
heappush(queue, [length[start], start])

while queue:
current_length, current_target = heappop(queue)

if length[current_target] < current_length :
continue

for new_target, new_length in graph[current_target] :
len = current_length + new_length
if len < length[new_target]:
length[new_target] = len
heappush(queue, [len, new_target])
return length

items = []
N,M,R = map(int, input().split())
T = list(map(int, input().split()))
graph = [[] for _ in range(N+1)]

for _ in range(R):
start, end, weight = map(int, input().split())
graph[start].append((end, weight))
graph[end].append((start, weight))

for item in range(1, len(graph)) :
result = dijkstra(graph, item)
get = 0
for i in range(len(result)):
if result[i] <= M :
get += T[i-1]
items.append(get)

print(max(items))
49 changes: 49 additions & 0 deletions wkdghdwns199/๋ฆฌ๋ทฐํ’€์ด/ACM-16235.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import sys
from collections import deque
input = sys.stdin.readline

dx = [-1,-1,-1,0,0,1,1,1]
dy = [-1,0,1,-1,1,-1,0,1]

N,M,K = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
trees = [[deque() for _ in range(N)] for _ in range(N)]

for _ in range(M) :
x,y,z = map(int, input().split())
trees[x-1][y-1].append(z)

ground = [[5] * N for _ in range(N)]
for _ in range(K) :

for i in range(N) :
for j in range(N):
trees_length = len(trees[i][j])
for k in range(trees_length) :
if ground[i][j] >= trees[i][j][k] :
ground[i][j] -= trees[i][j][k]
trees[i][j][k] += 1
else :
for _ in range(k,trees_length):
ground[i][j] += trees[i][j].pop() // 2
break

for i in range(N):
for j in range(N) :
for z in trees[i][j] :
if z % 5 == 0:
for idx in range(8):
move_x = i + dx[idx]
move_y = j + dy[idx]
if 0 <= move_x < N and 0 <= move_y < N :
trees[move_x][move_y].appendleft(1)
ground[i][j] += A[i][j]

answer = 0
for i in range(N) :
for j in range(N):
answer += len(trees[i][j])
print(answer)



12 changes: 12 additions & 0 deletions wkdghdwns199/๋ฆฌ๋ทฐํ’€์ด/ACM-1629.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import sys
input = sys.stdin.readline

def power(A,B,C):
if (B == 1) : return A%C
else :
temp = power(A,B//2, C)
if (B%2 == 0) : return temp * temp % C
else : return temp * temp * A % C

A,B,C = map(int, input().split())
print(power(A,B,C))
17 changes: 17 additions & 0 deletions wkdghdwns199/๋ฆฌ๋ทฐํ’€์ด/ACM-2170.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import sys
input = sys.stdin.readline
N = int(input())
lines = [list(map(int, input().rstrip().split())) for _ in range(N)]
lines.sort()

length =0
current_start = lines[0][0]
current_end = lines[0][1]
for start, end in lines[1:]:
if start > current_end :
print(start, current_end)
length += (current_end - current_start)
current_start = start
current_end = max(current_end, end)
length += (current_end - current_start)
print(length)
24 changes: 24 additions & 0 deletions wkdghdwns199/์šฐ์„ ์ˆœ์œ„_ํ/ACM-11286.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import sys, heapq
input =sys.stdin.readline
min_heap = []
max_heap = []
N = int(input())
for _ in range(N):
number = int(input())
if (number > 0) :
heapq.heappush(min_heap, number)
elif (number < 0) :
heapq.heappush(max_heap, -number)
else :
if min_heap :
if max_heap :
if min_heap[0] < max_heap[0] :
print(heapq.heappop(min_heap))
else :
print(-heapq.heappop(max_heap))
else :
print(heapq.heappop(min_heap))
elif max_heap :
print(-heapq.heappop(max_heap))
else :
print(0)
20 changes: 20 additions & 0 deletions wkdghdwns199/์ง‘ํ•ฉ๊ณผ_๋งต/ACM-20902.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import sys
input = sys.stdin.readline
N,M = map(int, input().split())
word_count = {}
for _ in range(N):
word = input().rstrip()
if len(word) >= M :
if word in word_count :
word_count[word][0] += 1
else :
word_count[word] = [1,len(word)]

print()
for key in word_count :
print (key)

sorted_word_list = sorted(word_count, key=lambda key : (-word_count[key][0], -word_count[key][1], key))
print()
for word in sorted_word_list :
print(word)

0 comments on commit 62f5587

Please sign in to comment.