diff --git a/.gitignore b/.gitignore index 73dcb74..b9f4630 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ .DS_Store .idea/ /.vscode +cmake-build-debug/ +CMakeLists.txt \ No newline at end of file diff --git a/g0rnn/README.md b/g0rnn/README.md index f8dcc1e..8e49311 100644 --- a/g0rnn/README.md +++ b/g0rnn/README.md @@ -1,15 +1,17 @@ ## ✏️ 기록 -| 차시 | 날짜 | 문제유형 | 링크 | 풀이 | -| :---: | :--------: | :--------: | :---------------------------------------------------------------------------: | :-------------------------------------------------: | -| 1차시 | 2024.10.01 | 구현 | [추억 점수](https://school.programmers.co.kr/learn/courses/30/lessons/176963) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/35 | -| 2차시 | 2024.10.03 | 트리 | [LCA2](https://school.programmers.co.kr/learn/courses/30/lessons/176963) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/7 | -| 3차시 | 2024.10.04 | 문자열 | [잃어버린 괄호](https://www.acmicpc.net/problem/1541) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/9 | -| 4차시 | 2024.10.11 | 브루트포스 | [영화감독 숌](https://www.acmicpc.net/problem/1436) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/15 | -| 5차시 | 2024.11.01 | BFS/DFS | [연구소](https://www.acmicpc.net/problem/14502) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/17 | -| 6차시 | 2024.11.06 | 구현 | [통계학](https://www.acmicpc.net/problem/2108) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/23 | -| 7차시 | 2024.11.25 | 구현 | [팰린드롬 만들기](https://www.acmicpc.net/problem/1213) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/31 | -| 8차시 | 2024.11.29 | 문자열 | [잠수함식별](https://www.acmicpc.net/problem/2671) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/35 | -| 9차시 | 2024.12.04 | 그리디 | [A->B](https://www.acmicpc.net/problem/16953) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/39 | +| 차시 | 날짜 | 문제유형 | 링크 | 풀이 | +|:----:|:----------:|:-------:|:-------------------------------------------------------------------------:|:---------------------------------------------------:| +| 1차시 | 2024.10.01 | 구현 | [추억 점수](https://school.programmers.co.kr/learn/courses/30/lessons/176963) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/35 | +| 2차시 | 2024.10.03 | 트리 | [LCA2](https://school.programmers.co.kr/learn/courses/30/lessons/176963) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/7 | +| 3차시 | 2024.10.04 | 문자열 | [잃어버린 괄호](https://www.acmicpc.net/problem/1541) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/9 | +| 4차시 | 2024.10.11 | 브루트포스 | [영화감독 숌](https://www.acmicpc.net/problem/1436) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/15 | +| 5차시 | 2024.11.01 | BFS/DFS | [연구소](https://www.acmicpc.net/problem/14502) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/17 | +| 6차시 | 2024.11.06 | 구현 | [통계학](https://www.acmicpc.net/problem/2108) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/23 | +| 7차시 | 2024.11.25 | 구현 | [팰린드롬 만들기](https://www.acmicpc.net/problem/1213) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/31 | +| 8차시 | 2024.11.29 | 문자열 | [잠수함식별](https://www.acmicpc.net/problem/2671) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/35 | +| 9차시 | 2024.12.04 | 그리디 | [A->B](https://www.acmicpc.net/problem/16953) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/39 | +| 10차시 | 2024.12.20 | 그래프 | [결혼식](https://www.acmicpc.net/problem/5567) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/40 | +| 11차시 | 2024.12.30 | dp | [기타리스트](https://www.acmicpc.net/problem/1495) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/49 | --- diff --git a/g0rnn/dp/11-g0rnn.cpp b/g0rnn/dp/11-g0rnn.cpp new file mode 100644 index 0000000..4ff7d28 --- /dev/null +++ b/g0rnn/dp/11-g0rnn.cpp @@ -0,0 +1,38 @@ +// +// Created by 김균호 on 2024. 12. 31.. +// +// 1. 조절한 볼륨이 0보다 작거나 max보다 크면 연주할 수 없다 -> -1 +// 2. 범위 내의 최댓값을 구하라 + +#include +using namespace std; + +int n, s, m; +int v[55]; +bool dp[55][1005]; +int ans = -1; + +int main() { + cin >> n >> s >> m; + for (int i = 1; i <= n; i++) + cin >> v[i]; + + if (s + v[1] <= m) dp[1][s + v[1]] = true; + if (s - v[1] >= 0) dp[1][s - v[1]] = true; + + for (int i = 2; i <= n; i++) { + for (int j = 0; j <= m; j++) { + if (!dp[i - 1][j]) continue; + if (j + v[i] <= m) dp[i][j + v[i]] = true; + if (j - v[i] >= 0) dp[i][j - v[i]] = true; + } + } + for (int i = m; i >= 0; i--) { + if (dp[n][i]) { + ans = i; + break; + } + } + cout << ans; + return 0; +} diff --git a/g0rnn/graph/10-g0rnn.cpp b/g0rnn/graph/10-g0rnn.cpp new file mode 100644 index 0000000..45664a3 --- /dev/null +++ b/g0rnn/graph/10-g0rnn.cpp @@ -0,0 +1,38 @@ +// +// Created by 김균호 on 2024. 12. 20.. +// +#include +#include +#include +using namespace std; + +const int SANG = 1; +int n, m; +int ret = 0; +vector > relationship; +unordered_set members = {1}; + +int main() { + cin >> n >> m; + relationship = vector >(n + 1); + int a, b; + + for (int i = 0; i < m; i++) { + cin >> a >> b; + // + if (a == SANG) members.insert(b); + // make a graph + relationship[a].insert(b); + relationship[b].insert(a); + } + + // find friends' friends + for (auto f: relationship[SANG]) { + for (auto r: relationship[f]) { + members.insert(r); + } + } + + // exclude SANG + cout << members.size() - 1; +}