Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
# Conflicts:
#	InSange/README.md
  • Loading branch information
InSange committed May 26, 2024
2 parents 2ddf2f3 + 0d5e4b2 commit a584769
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 2 deletions.
10 changes: 8 additions & 2 deletions dhlee777/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
| 2차시 | 2024.03.18 | DP | [쉬운계단수](https://www.acmicpc.net/problem/10844) | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/8)|
| 3차시 | 2024.03.23 | union-find | [집합의 표현](https://www.acmicpc.net/problem/1717) | [#14](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/14)|
| 4차시 | 2024.03.25 | BFS | [바이러스](https://www.acmicpc.net/problem/2606) | [#17](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/17)|
| 5차시 | 2024.03.30 | mst | [최소스패닝트리](https://www.acmicpc.net/problem/1197) | [#21](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/21)|
| 5차시 | 2024.03.30 | MST | [최소스패닝트리](https://www.acmicpc.net/problem/1197) | [#21](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/21)|
| 6차시 | 2024.04.04 | backtracking | [스타트와링크](https://www.acmicpc.net/problem/14889) | [#29](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/29)|
| 7차시 | 2024.04.08 | backtracking | [n과m(5)](https://www.acmicpc.net/problem/15654) | [#31](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/31)|
| 7차시 | 2024.04.08 | backtracking | [n과m(5)](https://www.acmicpc.net/problem/15654) | [#31](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/31)|
| 8차시 | 2024.04.12 | DFS | [적록색약](https://www.acmicpc.net/problem/10026) | [#35](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/35)|
| 9차시 | 2024.05.06 | 문자열처리 | [AC](https://www.acmicpc.net/problem/5430) | [#42](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/42)|
| 10차시| 2024.05.10 | BFS | [토마토](https://www.acmicpc.net/problem/7569) | [#47](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/47)|
| 11차시| 2024.05.11 | DP | [1로만들기](https://www.acmicpc.net/problem/1463) | [#48](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/48)|
| 12차시| 2024.05.13 | union-find | [연결요소의개수](https://www.acmicpc.net/problem/11724) | [#51](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/51)|
---
21 changes: 21 additions & 0 deletions dhlee777/dp/1로만들기.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include<iostream>
using namespace std;
int dp[1000001];
int main(void) {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int num;
cin >> num;
dp[1] = 0;
dp[2] = 1;
dp[3] = 1;
for (int i = 4; i <= num; i++) {
dp[i] = dp[i - 1] + 1;
if (i % 3 == 0)
dp[i] = min(dp[i], dp[i / 3] + 1);
if (i % 2 == 0)
dp[i] = min(dp[i], dp[i / 2] + 1);
}
cout << dp[num];

}
34 changes: 34 additions & 0 deletions dhlee777/union-find/연결요소의개수.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include<iostream>
#include<set>
using namespace std;
int parent[1001];
set<int>s;
int find_parent(int a) {
if (parent[a] == a) return a;
else return parent[a]=find_parent(parent[a]);
}
void unionn(int a, int b) {
int root_a = find_parent(a);
int root_b = find_parent(b);
if (a == b) return;
if (root_a < root_b) parent[root_b] = root_a;
else parent[root_a] = root_b;
}
int main(void) {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int v, e,v1,v2;
cin >> v >> e;
for (int j = 1; j <= v; j++) {
parent[j] = j;
}
for (int i = 0; i < e; i++) {
cin >> v1 >> v2;
unionn(v1, v2);
}
for (int i = 1; i <= v; i++) {
int v3=find_parent(i);
s.insert(v3);
}
cout << s.size();
}
21 changes: 21 additions & 0 deletions seongwon030/브루트포스/암호만들기.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from itertools import combinations

L,C = map(int,input().split())

k = list(map(str,input().split()))
vowels = 'aeiou'

vowel_cnt = 0
consonant_cnt = 0

result = []
for c in combinations(k,L):
vowel_str = ''.join(sorted(c))
vowel_cnt = sum(1 for char in vowel_str if char in vowels)
consonant_cnt = L - vowel_cnt
if vowel_cnt >=1 and consonant_cnt >=2:
result.append(vowel_str)

result.sort()
for word in result:
print(word)
72 changes: 72 additions & 0 deletions yuyu0830/그리디/1826.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#include <iostream>
#include <queue>

using namespace std;

typedef pair<int, int> ii;

struct cmp{
bool operator() (ii &a, ii &b) {
if (a.first > b.first) return true;
return false;
}
};

struct cmpB{
bool operator() (ii &a, ii &b) {
if (a.second < b.second) return true;
return false;
}
};

int main() {
priority_queue<ii, vector<ii>, cmp> q;

int n; cin >> n;
for (int i = 0; i < n; i++) {
int a, b; cin >> a >> b;
q.push(make_pair(a, b));
}

int dest, fuel; cin >> dest >> fuel;
int cur = 0, ans = 0;

priority_queue<ii, vector<ii>, cmpB> reachable;

while (cur <= dest) {
while (!q.empty()) {
if (q.top().first <= cur + fuel) {
reachable.push(q.top());
q.pop();
}
else break;
}

while (true) {
if (cur + fuel >= dest) {
printf("%d\n", ans);
return 0;
}

if (reachable.empty()) {
printf("-1\n");
return 0;
}

int f = reachable.top().first;
int s = reachable.top().second;

if (f > cur) fuel -= f - cur;
fuel += s;

cur = f > cur ? f : cur;
ans++;

reachable.pop();

if (q.top().first <= cur + fuel) break;
}
}

printf("%d\n", ans);
}

0 comments on commit a584769

Please sign in to comment.