Skip to content

Commit a349dc8

Browse files
authored
Merge branch 'main' into 30-yuna83
2 parents 276008a + 7138d16 commit a349dc8

15 files changed

+374
-1
lines changed

โ€ŽMunbin-Lee/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,9 @@
3232
| 29์ฐจ์‹œ | 2024.01.19 | ์œ ๋‹ˆ์˜จํŒŒ์ธ๋“œ | <a href="https://www.acmicpc.net/problem/1043">๊ฑฐ์ง“๋ง</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/114 |
3333
| 30์ฐจ์‹œ | 2024.01.23 | ์ •์ˆ˜๋ก  | <a href="https://www.acmicpc.net/problem/17425">์•ฝ์ˆ˜์˜ ํ•ฉ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/118 |
3434
| 31์ฐจ์‹œ | 2024.01.27 | ์ด๋ถ„ํƒ์ƒ‰ | <a href="https://www.acmicpc.net/problem/2143">๋‘ ๋ฐฐ์—ด์˜ ํ•ฉ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/122 |
35+
| 32์ฐจ์‹œ | 2024.01.30 | ๋ฐฑํŠธ๋ž˜ํ‚น | <a href="https://www.acmicpc.net/problem/17114">ํ•˜์ดํผ ํ† ๋งˆํ† </a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/124 |
3536
| 33์ฐจ์‹œ | 2024.02.04 | ์ •์ˆ˜๋ก  | <a href="https://www.acmicpc.net/problem/14905">์†Œ์ˆ˜ 4๊ฐœ์˜ ํ•ฉ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/128 |
37+
| 34์ฐจ์‹œ | 2024.02.06 | ๊ตฌํ˜„ | <a href="https://www.acmicpc.net/problem/1756">ํ”ผ์ž ๊ตฝ๊ธฐ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/133 |
38+
| 35์ฐจ์‹œ | 2024.02.18 | ๋ฐฑํŠธ๋ž˜ํ‚น | <a href="https://www.acmicpc.net/problem/24891">๋‹จ์–ด ๋งˆ๋ฐฉ์ง„</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/140 |
39+
| 36์ฐจ์‹œ | 2024.02.21 | ๋ฌธ์ž์—ด | <a href="https://www.acmicpc.net/problem/15927">ํšŒ๋ฌธ์€ ํšŒ๋ฌธ์•„๋‹ˆ์•ผ!!</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/143 |
3640
---
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include <iostream>
2+
#include <stack>
3+
4+
using namespace std;
5+
6+
int main() {
7+
ios_base::sync_with_stdio(false);
8+
cin.tie(nullptr);
9+
10+
int D, N;
11+
cin >> D >> N;
12+
13+
stack<int> minOvens;
14+
int mn = 1087654321;
15+
16+
while (D--) {
17+
int oven;
18+
cin >> oven;
19+
20+
mn = min(mn, oven);
21+
minOvens.emplace(mn);
22+
}
23+
24+
while (N--) {
25+
int pizza;
26+
cin >> pizza;
27+
28+
while (!minOvens.empty() && minOvens.top() < pizza) {
29+
minOvens.pop();
30+
}
31+
32+
if (!minOvens.empty()) {
33+
minOvens.pop();
34+
} else {
35+
cout << '0';
36+
return 0;
37+
}
38+
}
39+
40+
cout << minOvens.size() + 1;
41+
42+
return 0;
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include <iostream>
2+
#include <unordered_set>
3+
4+
using namespace std;
5+
6+
int main() {
7+
ios_base::sync_with_stdio(false);
8+
cin.tie(nullptr);
9+
10+
string s;
11+
cin >> s;
12+
13+
if (unordered_set<char>(s.begin(), s.end()).size() == 1) {
14+
cout << "-1";
15+
return 0;
16+
}
17+
18+
auto isPalindrome = [](string &s) {
19+
int lo = 0;
20+
int hi = s.size() - 1; // NOLINT
21+
22+
while (lo < hi) {
23+
if (s[lo] != s[hi]) return false;
24+
lo++;
25+
hi--;
26+
}
27+
28+
return true;
29+
};
30+
31+
if (!isPalindrome(s)) {
32+
cout << s.size();
33+
return 0;
34+
}
35+
36+
cout << s.size() - 1;
37+
38+
return 0;
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
from math import prod
2+
from collections import deque
3+
4+
stdin = open(0)
5+
sizes = list(map(int, stdin.readline().split()))
6+
totalSize = prod(sizes)
7+
board = []
8+
unripe = 0
9+
index = 0
10+
deq = deque()
11+
12+
for line in stdin.read().splitlines():
13+
for num in map(int, line.split()):
14+
board.append(num)
15+
16+
if num == 0:
17+
unripe += 1
18+
19+
if num == 1:
20+
deq.append(index)
21+
22+
index += 1
23+
24+
if unripe == 0:
25+
print('0')
26+
exit()
27+
28+
def extract(x):
29+
answer = [0] * 11
30+
divisor = totalSize
31+
32+
for i in range(10, -1, -1):
33+
divisor //= sizes[i]
34+
answer[i] = x // divisor
35+
x %= divisor
36+
37+
return answer
38+
39+
def compress(ls):
40+
answer = 0
41+
coefficient = 1
42+
43+
for i in range(0, 11):
44+
answer += ls[i] * coefficient
45+
coefficient *= sizes[i]
46+
47+
return answer
48+
49+
while deq:
50+
cur = deq.popleft()
51+
positions = extract(cur)
52+
53+
for i in range(0, 11):
54+
for offset in (-1, 1):
55+
positions[i] += offset
56+
57+
if 0 <= positions[i] < sizes[i]:
58+
next = compress(positions)
59+
60+
if board[next] == 0:
61+
board[next] = board[cur] + 1
62+
unripe -= 1
63+
deq.append(next)
64+
65+
positions[i] -= offset
66+
67+
if unripe == 0:
68+
print(board[cur])
69+
exit()
70+
71+
print('-1')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from itertools import permutations
2+
3+
stdin = open(0)
4+
5+
L, N = map(int, stdin.readline().split())
6+
words = sorted(stdin.read().splitlines())
7+
8+
# ๋‹จ์–ด ์ˆœ์—ด x๊ฐ€ ๋‹จ์–ด ๋งˆ๋ฐฉ์ง„์ธ์ง€ ํ™•์ธํ•˜๋Š” ํ•จ์ˆ˜
9+
def isValid(x):
10+
for i in range(L):
11+
for j in range(L):
12+
if x[i][j] != x[j][i]: return False
13+
14+
return True
15+
16+
for perm in permutations(words, L):
17+
if not isValid(perm): continue
18+
19+
print(*perm, sep='\n')
20+
exit()
21+
22+
print('NONE')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from sys import *
2+
from collections import *
3+
4+
n, k = map(int, stdin.readline().strip().split())
5+
6+
max_idx = 100001
7+
8+
q = deque([(n, 0)])
9+
visited = [False] * max_idx
10+
visited[n] = True
11+
12+
while q:
13+
x, cost = q.popleft()
14+
if x == k:
15+
print(cost)
16+
break
17+
18+
nx = x + x
19+
if nx < max_idx and not visited[nx]:
20+
visited[nx] = True
21+
q.appendleft((nx, cost))
22+
23+
nx = x - 1
24+
if 0 <= nx and not visited[nx]:
25+
visited[nx] = True
26+
q.append((nx, cost + 1))
27+
28+
nx = x + 1
29+
if nx < max_idx and not visited[nx]:
30+
visited[nx] = True
31+
q.append((nx, cost + 1))

โ€Žpknujsp/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@
3232
| 28์ฐจ์‹œ | 2024.01.16 | ๊ทธ๋ฆฌ๋”” | [๋ฌด์ง€์˜ ๋จน๋ฐฉ ๋ผ์ด๋ธŒ](https://school.programmers.co.kr/learn/courses/30/lessons/42891) | [#110](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/110) |
3333
| 29์ฐจ์‹œ | 2024.01.18 | DFS, UNION-FIND | [์ˆœ์—ด ์‚ฌ์ดํด](https://www.acmicpc.net/problem/10451) | [#112](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/112) |
3434
| 30์ฐจ์‹œ | 2024.01.23 | DP | [ABBC](https://www.acmicpc.net/problem/25381) | [#119](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/119) |
35-
| 31์ฐจ์‹œ | 2024.01.30 | SORT | [๋ฉ€ํ‹ฐ๋ฒ„์Šค โ…ก](https://www.acmicpc.net/problem/18869) | [#123](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/123) |
35+
| 31์ฐจ์‹œ | 2024.01.30 | SORT | [๋ฉ€ํ‹ฐ๋ฒ„์Šค โ…ก](https://www.acmicpc.net/problem/18869) | [#123](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/123) |
36+
| 32์ฐจ์‹œ | 2024.02.04 | BFS | [์ˆจ๋ฐ”๊ผญ์งˆ 3](https://www.acmicpc.net/problem/13549) | [#127](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/127) |

โ€ŽtgyuuAn/BFS/๊ตํ™˜.py

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
from collections import Counter
2+
3+
number, exchange_count = map(int,input().split())
4+
5+
number = list(str(number))
6+
answer = "0"
7+
8+
counter = Counter(number)
9+
same_number_flag = False
10+
11+
for key, value in counter.items():
12+
if value >=2:
13+
same_number_flag = True
14+
break
15+
16+
def dfs(number, depth, remain_exchange_count, same_number_flag):
17+
global answer
18+
19+
if remain_exchange_count == 0:
20+
answer = max(answer, "".join(number))
21+
return
22+
23+
flag = False
24+
for prev_idx in range(depth,len(number)):
25+
for next_idx in range(prev_idx+1, len(number)):
26+
if number[next_idx] >= number[prev_idx]:
27+
number[next_idx], number[prev_idx] = number[prev_idx], number[next_idx]
28+
dfs(number, depth+1, remain_exchange_count-1, same_number_flag)
29+
number[next_idx], number[prev_idx] = number[prev_idx], number[next_idx]
30+
flag = True
31+
32+
if flag == False:
33+
if same_number_flag: dfs(number, depth+1, remain_exchange_count-1, same_number_flag)
34+
else:
35+
number[-1], number[-2] = number[-2], number[-1]
36+
dfs(number, depth+1, remain_exchange_count-1, same_number_flag)
37+
number[-1], number[-2] = number[-2], number[-1]
38+
39+
if len(number) == 1 and exchange_count >= 1:
40+
print("-1")
41+
42+
elif len(number) == 2 and "0" in number:
43+
print("-1")
44+
45+
else:
46+
dfs(number,0, exchange_count, same_number_flag)
47+
print(answer)

โ€ŽtgyuuAn/DP/์•ฑ.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
total_app_count, need_memory = map(int,input().split())
2+
3+
use_memory = list(map(int,input().split()))
4+
re_use_cost = list(map(int,input().split()))
5+
6+
dp_table = [0 for _ in range(sum(re_use_cost)+1)]
7+
cost_sum = sum(re_use_cost)
8+
9+
for memory, cost in zip(use_memory, re_use_cost):
10+
for idx in range(cost_sum,cost-1,-1):
11+
dp_table[idx] = max(dp_table[idx], dp_table[idx-cost] + memory)
12+
13+
for idx, memory in enumerate(dp_table):
14+
if memory >= need_memory:
15+
print(idx)
16+
break

โ€ŽtgyuuAn/DP/์ž…๋Œ€.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import sys
2+
3+
remain_days, need_score = map(int,sys.stdin.readline().split())
4+
volunteer_scores = [0]
5+
volunteer_scores.extend(list(map(int,sys.stdin.readline().split())))
6+
7+
blood_donation_score, blood_donation_break_time = map(int,sys.stdin.readline().split())
8+
9+
volunteer_scores.extend([0 for _ in range(blood_donation_break_time-1)])
10+
maximum_blood_donation_count = (len(volunteer_scores)+blood_donation_break_time-1)//blood_donation_break_time+1
11+
12+
dp_table = [[0 for _ in range(maximum_blood_donation_count)] for _ in range(len(volunteer_scores))]
13+
14+
for date in range(len(volunteer_scores)):
15+
if date >= blood_donation_break_time:
16+
for blood_donation_count in range(1,maximum_blood_donation_count):
17+
dp_table[date][blood_donation_count] = max(dp_table[date][blood_donation_count],
18+
dp_table[date-1][blood_donation_count] + volunteer_scores[date],
19+
dp_table[date-blood_donation_break_time][blood_donation_count-1] + blood_donation_score)
20+
21+
dp_table[date][0] = dp_table[date-1][0] + volunteer_scores[date]
22+
23+
print(dp_table)
24+
25+
for count in range(len(dp_table[-1])):
26+
if dp_table[-1][count] >= need_score:
27+
print(count)
28+
break
29+
30+
else: print(-1)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
target = int(input())
2+
3+
M = 1_000_000
4+
period = 1_500_000
5+
6+
target %= period
7+
8+
dp_table = [0 for _ in range(3)]
9+
dp_table[0] = 0
10+
dp_table[1] = 1
11+
12+
for idx in range(2,target+1):
13+
idx %= 3
14+
dp_table[idx] = dp_table[idx-1] % M + dp_table[idx-2] % M
15+
16+
print(dp_table[target%3]%M)

โ€ŽtgyuuAn/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,8 @@
3838
| 34์ฐจ์‹œ | 2023.01.22 | ํž™ | <a href="https://www.acmicpc.net/problem/1655">๊ฐ€์šด๋ฐ๋ฅผ ๋งํ•ด์š”</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/116
3939
| 35์ฐจ์‹œ | 2023.01.25 | ์ด๋ถ„ ํƒ์ƒ‰ | <a href="https://www.acmicpc.net/problem/2110">๊ณต์œ ๊ธฐ ์„ค์น˜</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/120
4040
| 36์ฐจ์‹œ | 2023.02.04 | BFS | <a href="https://www.acmicpc.net/problem/4991">๋กœ๋ด‡ ์ฒญ์†Œ๊ธฐ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/126
41+
| 37์ฐจ์‹œ | 2023.02.04 | BFS | <a href="https://www.acmicpc.net/problem/1039">๊ตํ™˜</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/131
42+
| 38์ฐจ์‹œ | 2023.02.15 | DP | <a href="https://www.acmicpc.net/problem/2749">ํ”ผ๋ณด๋‚˜์น˜ ์ˆ˜ 3</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/137
43+
| 39์ฐจ์‹œ | 2023.02.18 | DP | <a href="https://www.acmicpc.net/problem/7579">์•ฑ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/139
44+
| 40์ฐจ์‹œ | 2023.02.21 | DP | <a href="https://www.acmicpc.net/problem/31413">์ž…๋Œ€</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/142
4145
---
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
cnt=0
2+
def DFS(virus):
3+
global cnt
4+
visited[virus]=1
5+
6+
for i in network[virus]:
7+
if (visited[i]==0):
8+
DFS(i)
9+
cnt+=1
10+
11+
N= int(input())
12+
link = int(input())
13+
14+
network = [[]*(N+1) for _ in range(N+1)]
15+
for i in range(link):
16+
a, b = map(int, input().split())
17+
network[a].append(b)
18+
network[b].append(a)
19+
visited = [0]*(N+1)
20+
DFS(1)
21+
print(cnt)

โ€Žyuna83/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,6 @@
3232
| 28์ฐจ์‹œ | 2024.02.07 | ํˆฌํฌ์ธํ„ฐ | [๊ตฌ๋ช…๋ณดํŠธ](https://school.programmers.co.kr/learn/courses/30/lessons/42885)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/134|
3333
| 29์ฐจ์‹œ | 2024.02.13 | ์Šฌ๋ผ์ด๋”ฉ์œˆ๋„์šฐ | [๋ธ”๋กœ๊ทธ](https://www.acmicpc.net/problem/21921)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/136|
3434
| 29์ฐจ์‹œ | 2024.02.19 | ์Šฌ๋ผ์ด๋”ฉ์œˆ๋„์šฐ | [๋„๋‘‘](https://www.acmicpc.net/problem/13422)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/141|
35+
| 30์ฐจ์‹œ | 2024.02.19 | ์Šฌ๋ผ์ด๋”ฉ์œˆ๋„์šฐ | [๋„๋‘‘](https://www.acmicpc.net/problem/13422)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/141|
36+
| 31์ฐจ์‹œ | 2024.02.23 | DFS/BFS | [๋ฐ”์ด๋Ÿฌ์Šค](https://www.acmicpc.net/problem/2606)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/145|
3537
---

0 commit comments

Comments
ย (0)