Skip to content

Commit

Permalink
Merge branch 'main' into 30-yuna83
Browse files Browse the repository at this point in the history
  • Loading branch information
yuna83 authored Mar 4, 2024
2 parents 276008a + 7138d16 commit a349dc8
Show file tree
Hide file tree
Showing 15 changed files with 374 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Munbin-Lee/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,9 @@
| 29์ฐจ์‹œ | 2024.01.19 | ์œ ๋‹ˆ์˜จํŒŒ์ธ๋“œ | <a href="https://www.acmicpc.net/problem/1043">๊ฑฐ์ง“๋ง</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/114 |
| 30์ฐจ์‹œ | 2024.01.23 | ์ •์ˆ˜๋ก  | <a href="https://www.acmicpc.net/problem/17425">์•ฝ์ˆ˜์˜ ํ•ฉ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/118 |
| 31์ฐจ์‹œ | 2024.01.27 | ์ด๋ถ„ํƒ์ƒ‰ | <a href="https://www.acmicpc.net/problem/2143">๋‘ ๋ฐฐ์—ด์˜ ํ•ฉ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/122 |
| 32์ฐจ์‹œ | 2024.01.30 | ๋ฐฑํŠธ๋ž˜ํ‚น | <a href="https://www.acmicpc.net/problem/17114">ํ•˜์ดํผ ํ† ๋งˆํ† </a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/124 |
| 33์ฐจ์‹œ | 2024.02.04 | ์ •์ˆ˜๋ก  | <a href="https://www.acmicpc.net/problem/14905">์†Œ์ˆ˜ 4๊ฐœ์˜ ํ•ฉ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/128 |
| 34์ฐจ์‹œ | 2024.02.06 | ๊ตฌํ˜„ | <a href="https://www.acmicpc.net/problem/1756">ํ”ผ์ž ๊ตฝ๊ธฐ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/133 |
| 35์ฐจ์‹œ | 2024.02.18 | ๋ฐฑํŠธ๋ž˜ํ‚น | <a href="https://www.acmicpc.net/problem/24891">๋‹จ์–ด ๋งˆ๋ฐฉ์ง„</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/140 |
| 36์ฐจ์‹œ | 2024.02.21 | ๋ฌธ์ž์—ด | <a href="https://www.acmicpc.net/problem/15927">ํšŒ๋ฌธ์€ ํšŒ๋ฌธ์•„๋‹ˆ์•ผ!!</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/143 |
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include <iostream>
#include <stack>

using namespace std;

int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);

int D, N;
cin >> D >> N;

stack<int> minOvens;
int mn = 1087654321;

while (D--) {
int oven;
cin >> oven;

mn = min(mn, oven);
minOvens.emplace(mn);
}

while (N--) {
int pizza;
cin >> pizza;

while (!minOvens.empty() && minOvens.top() < pizza) {
minOvens.pop();
}

if (!minOvens.empty()) {
minOvens.pop();
} else {
cout << '0';
return 0;
}
}

cout << minOvens.size() + 1;

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <iostream>
#include <unordered_set>

using namespace std;

int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);

string s;
cin >> s;

if (unordered_set<char>(s.begin(), s.end()).size() == 1) {
cout << "-1";
return 0;
}

auto isPalindrome = [](string &s) {
int lo = 0;
int hi = s.size() - 1; // NOLINT

while (lo < hi) {
if (s[lo] != s[hi]) return false;
lo++;
hi--;
}

return true;
};

if (!isPalindrome(s)) {
cout << s.size();
return 0;
}

cout << s.size() - 1;

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
from math import prod
from collections import deque

stdin = open(0)
sizes = list(map(int, stdin.readline().split()))
totalSize = prod(sizes)
board = []
unripe = 0
index = 0
deq = deque()

for line in stdin.read().splitlines():
for num in map(int, line.split()):
board.append(num)

if num == 0:
unripe += 1

if num == 1:
deq.append(index)

index += 1

if unripe == 0:
print('0')
exit()

def extract(x):
answer = [0] * 11
divisor = totalSize

for i in range(10, -1, -1):
divisor //= sizes[i]
answer[i] = x // divisor
x %= divisor

return answer

def compress(ls):
answer = 0
coefficient = 1

for i in range(0, 11):
answer += ls[i] * coefficient
coefficient *= sizes[i]

return answer

while deq:
cur = deq.popleft()
positions = extract(cur)

for i in range(0, 11):
for offset in (-1, 1):
positions[i] += offset

if 0 <= positions[i] < sizes[i]:
next = compress(positions)

if board[next] == 0:
board[next] = board[cur] + 1
unripe -= 1
deq.append(next)

positions[i] -= offset

if unripe == 0:
print(board[cur])
exit()

print('-1')
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from itertools import permutations

stdin = open(0)

L, N = map(int, stdin.readline().split())
words = sorted(stdin.read().splitlines())

# ๋‹จ์–ด ์ˆœ์—ด x๊ฐ€ ๋‹จ์–ด ๋งˆ๋ฐฉ์ง„์ธ์ง€ ํ™•์ธํ•˜๋Š” ํ•จ์ˆ˜
def isValid(x):
for i in range(L):
for j in range(L):
if x[i][j] != x[j][i]: return False

return True

for perm in permutations(words, L):
if not isValid(perm): continue

print(*perm, sep='\n')
exit()

print('NONE')
31 changes: 31 additions & 0 deletions pknujsp/BFS/32-์ˆจ๋ฐ”๊ผญ์งˆ 3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from sys import *
from collections import *

n, k = map(int, stdin.readline().strip().split())

max_idx = 100001

q = deque([(n, 0)])
visited = [False] * max_idx
visited[n] = True

while q:
x, cost = q.popleft()
if x == k:
print(cost)
break

nx = x + x
if nx < max_idx and not visited[nx]:
visited[nx] = True
q.appendleft((nx, cost))

nx = x - 1
if 0 <= nx and not visited[nx]:
visited[nx] = True
q.append((nx, cost + 1))

nx = x + 1
if nx < max_idx and not visited[nx]:
visited[nx] = True
q.append((nx, cost + 1))
3 changes: 2 additions & 1 deletion pknujsp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@
| 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) |
| 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) |
47 changes: 47 additions & 0 deletions tgyuuAn/BFS/๊ตํ™˜.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from collections import Counter

number, exchange_count = map(int,input().split())

number = list(str(number))
answer = "0"

counter = Counter(number)
same_number_flag = False

for key, value in counter.items():
if value >=2:
same_number_flag = True
break

def dfs(number, depth, remain_exchange_count, same_number_flag):
global answer

if remain_exchange_count == 0:
answer = max(answer, "".join(number))
return

flag = False
for prev_idx in range(depth,len(number)):
for next_idx in range(prev_idx+1, len(number)):
if number[next_idx] >= number[prev_idx]:
number[next_idx], number[prev_idx] = number[prev_idx], number[next_idx]
dfs(number, depth+1, remain_exchange_count-1, same_number_flag)
number[next_idx], number[prev_idx] = number[prev_idx], number[next_idx]
flag = True

if flag == False:
if same_number_flag: dfs(number, depth+1, remain_exchange_count-1, same_number_flag)
else:
number[-1], number[-2] = number[-2], number[-1]
dfs(number, depth+1, remain_exchange_count-1, same_number_flag)
number[-1], number[-2] = number[-2], number[-1]

if len(number) == 1 and exchange_count >= 1:
print("-1")

elif len(number) == 2 and "0" in number:
print("-1")

else:
dfs(number,0, exchange_count, same_number_flag)
print(answer)
16 changes: 16 additions & 0 deletions tgyuuAn/DP/์•ฑ.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
total_app_count, need_memory = map(int,input().split())

use_memory = list(map(int,input().split()))
re_use_cost = list(map(int,input().split()))

dp_table = [0 for _ in range(sum(re_use_cost)+1)]
cost_sum = sum(re_use_cost)

for memory, cost in zip(use_memory, re_use_cost):
for idx in range(cost_sum,cost-1,-1):
dp_table[idx] = max(dp_table[idx], dp_table[idx-cost] + memory)

for idx, memory in enumerate(dp_table):
if memory >= need_memory:
print(idx)
break
30 changes: 30 additions & 0 deletions tgyuuAn/DP/์ž…๋Œ€.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import sys

remain_days, need_score = map(int,sys.stdin.readline().split())
volunteer_scores = [0]
volunteer_scores.extend(list(map(int,sys.stdin.readline().split())))

blood_donation_score, blood_donation_break_time = map(int,sys.stdin.readline().split())

volunteer_scores.extend([0 for _ in range(blood_donation_break_time-1)])
maximum_blood_donation_count = (len(volunteer_scores)+blood_donation_break_time-1)//blood_donation_break_time+1

dp_table = [[0 for _ in range(maximum_blood_donation_count)] for _ in range(len(volunteer_scores))]

for date in range(len(volunteer_scores)):
if date >= blood_donation_break_time:
for blood_donation_count in range(1,maximum_blood_donation_count):
dp_table[date][blood_donation_count] = max(dp_table[date][blood_donation_count],
dp_table[date-1][blood_donation_count] + volunteer_scores[date],
dp_table[date-blood_donation_break_time][blood_donation_count-1] + blood_donation_score)

dp_table[date][0] = dp_table[date-1][0] + volunteer_scores[date]

print(dp_table)

for count in range(len(dp_table[-1])):
if dp_table[-1][count] >= need_score:
print(count)
break

else: print(-1)
16 changes: 16 additions & 0 deletions tgyuuAn/DP/ํ”ผ๋ณด๋‚˜์น˜ ์ˆ˜ 3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
target = int(input())

M = 1_000_000
period = 1_500_000

target %= period

dp_table = [0 for _ in range(3)]
dp_table[0] = 0
dp_table[1] = 1

for idx in range(2,target+1):
idx %= 3
dp_table[idx] = dp_table[idx-1] % M + dp_table[idx-2] % M

print(dp_table[target%3]%M)
4 changes: 4 additions & 0 deletions tgyuuAn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@
| 34์ฐจ์‹œ | 2023.01.22 | ํž™ | <a href="https://www.acmicpc.net/problem/1655">๊ฐ€์šด๋ฐ๋ฅผ ๋งํ•ด์š”</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/116
| 35์ฐจ์‹œ | 2023.01.25 | ์ด๋ถ„ ํƒ์ƒ‰ | <a href="https://www.acmicpc.net/problem/2110">๊ณต์œ ๊ธฐ ์„ค์น˜</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/120
| 36์ฐจ์‹œ | 2023.02.04 | BFS | <a href="https://www.acmicpc.net/problem/4991">๋กœ๋ด‡ ์ฒญ์†Œ๊ธฐ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/126
| 37์ฐจ์‹œ | 2023.02.04 | BFS | <a href="https://www.acmicpc.net/problem/1039">๊ตํ™˜</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/131
| 38์ฐจ์‹œ | 2023.02.15 | DP | <a href="https://www.acmicpc.net/problem/2749">ํ”ผ๋ณด๋‚˜์น˜ ์ˆ˜ 3</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/137
| 39์ฐจ์‹œ | 2023.02.18 | DP | <a href="https://www.acmicpc.net/problem/7579">์•ฑ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/139
| 40์ฐจ์‹œ | 2023.02.21 | DP | <a href="https://www.acmicpc.net/problem/31413">์ž…๋Œ€</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/142
---
21 changes: 21 additions & 0 deletions yuna83/DFS/๋ฐ”์ด๋Ÿฌ์Šค.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
cnt=0
def DFS(virus):
global cnt
visited[virus]=1

for i in network[virus]:
if (visited[i]==0):
DFS(i)
cnt+=1

N= int(input())
link = int(input())

network = [[]*(N+1) for _ in range(N+1)]
for i in range(link):
a, b = map(int, input().split())
network[a].append(b)
network[b].append(a)
visited = [0]*(N+1)
DFS(1)
print(cnt)
2 changes: 2 additions & 0 deletions yuna83/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@
| 28์ฐจ์‹œ | 2024.02.07 | ํˆฌํฌ์ธํ„ฐ | [๊ตฌ๋ช…๋ณดํŠธ](https://school.programmers.co.kr/learn/courses/30/lessons/42885)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/134|
| 29์ฐจ์‹œ | 2024.02.13 | ์Šฌ๋ผ์ด๋”ฉ์œˆ๋„์šฐ | [๋ธ”๋กœ๊ทธ](https://www.acmicpc.net/problem/21921)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/136|
| 29์ฐจ์‹œ | 2024.02.19 | ์Šฌ๋ผ์ด๋”ฉ์œˆ๋„์šฐ | [๋„๋‘‘](https://www.acmicpc.net/problem/13422)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/141|
| 30์ฐจ์‹œ | 2024.02.19 | ์Šฌ๋ผ์ด๋”ฉ์œˆ๋„์šฐ | [๋„๋‘‘](https://www.acmicpc.net/problem/13422)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/141|
| 31์ฐจ์‹œ | 2024.02.23 | DFS/BFS | [๋ฐ”์ด๋Ÿฌ์Šค](https://www.acmicpc.net/problem/2606)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/145|
---
Loading

0 comments on commit a349dc8

Please sign in to comment.