From 7243e70d94f55b9e3a7194e186f9839533b976e2 Mon Sep 17 00:00:00 2001 From: jung0115 Date: Tue, 27 Aug 2024 02:12:08 +0900 Subject: [PATCH 01/14] 2024-08-27 --- jung0115/README.md | 3 ++- .../Baekjoon_1188.java" | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 "jung0115/\354\210\230\355\225\231/Baekjoon_1188.java" diff --git a/jung0115/README.md b/jung0115/README.md index 9cab4e7..ed0eeff 100644 --- a/jung0115/README.md +++ b/jung0115/README.md @@ -9,4 +9,5 @@ | 5차시 | 2024.07.31.수 | 트리 / MST | [1251. [S/W 문제해결 응용] 4일차 - 하나로](https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV15StKqAQkCFAYD) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/137 | | 6차시 | 2024.08.03.토 | 트리 / 트라이 | [디스크 트리(7432)](https://www.acmicpc.net/problem/7432) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/142 | | 7차시 | 2024.08.07.수 | 다익스트라 | [지형 이동(Lv.4)](https://school.programmers.co.kr/learn/courses/30/lessons/62050) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/144 | -| 8차시 | 2024.08.19.월 | 이분 탐색 | [입국심사(Lv.3)](https://school.programmers.co.kr/learn/courses/30/lessons/43238) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/148 | \ No newline at end of file +| 8차시 | 2024.08.19.월 | 이분 탐색 | [입국심사(Lv.3)](https://school.programmers.co.kr/learn/courses/30/lessons/43238) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/148 | +| 9차시 | 2024.08.27.화 | 수학 | [음식 평론가(1188)](https://www.acmicpc.net/problem/1188) | | \ No newline at end of file diff --git "a/jung0115/\354\210\230\355\225\231/Baekjoon_1188.java" "b/jung0115/\354\210\230\355\225\231/Baekjoon_1188.java" new file mode 100644 index 0000000..2ec7504 --- /dev/null +++ "b/jung0115/\354\210\230\355\225\231/Baekjoon_1188.java" @@ -0,0 +1,23 @@ +// 9차시 2024.08.27.화 : 백준 - 음식 평론가(1188) +import java.io.InputStreamReader; +import java.io.BufferedReader; +import java.io.IOException; +import java.util.StringTokenizer; + +public class Baekjoon_1188 { + public static void main(String[] args) throws IOException { + BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(bf.readLine()); + int N = Integer.parseInt(st.nextToken()); // 소시지의 수 + int M = Integer.parseInt(st.nextToken()); // 평론가의 수 + + int answer = M - gcd(N, M); + System.out.println(answer); + } + + // 최대 공약수 - 유클리드 호제법 + static int gcd(int num1, int num2) { + if(num1 % num2 == 0) return num2; + return gcd(num2, num1 % num2); + } +} \ No newline at end of file From 51add42b4b389b167fcc0dd1b81332ed440b7dd6 Mon Sep 17 00:00:00 2001 From: jung0115 Date: Tue, 27 Aug 2024 02:12:52 +0900 Subject: [PATCH 02/14] 2024-08-27 readme --- jung0115/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jung0115/README.md b/jung0115/README.md index ed0eeff..4c37c5c 100644 --- a/jung0115/README.md +++ b/jung0115/README.md @@ -10,4 +10,4 @@ | 6차시 | 2024.08.03.토 | 트리 / 트라이 | [디스크 트리(7432)](https://www.acmicpc.net/problem/7432) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/142 | | 7차시 | 2024.08.07.수 | 다익스트라 | [지형 이동(Lv.4)](https://school.programmers.co.kr/learn/courses/30/lessons/62050) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/144 | | 8차시 | 2024.08.19.월 | 이분 탐색 | [입국심사(Lv.3)](https://school.programmers.co.kr/learn/courses/30/lessons/43238) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/148 | -| 9차시 | 2024.08.27.화 | 수학 | [음식 평론가(1188)](https://www.acmicpc.net/problem/1188) | | \ No newline at end of file +| 9차시 | 2024.08.27.화 | 수학 | [음식 평론가(1188)](https://www.acmicpc.net/problem/1188) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/150 | \ No newline at end of file From 45b0b58c889ff5d2ab088f3154094d8a84a7c49e Mon Sep 17 00:00:00 2001 From: jung0115 Date: Thu, 29 Aug 2024 02:46:58 +0900 Subject: [PATCH 03/14] 2024-08-28 --- jung0115/README.md | 3 +- .../Baekjoon_1034.kt" | 49 +++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 "jung0115/\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/Baekjoon_1034.kt" diff --git a/jung0115/README.md b/jung0115/README.md index 4c37c5c..33a0b02 100644 --- a/jung0115/README.md +++ b/jung0115/README.md @@ -10,4 +10,5 @@ | 6차시 | 2024.08.03.토 | 트리 / 트라이 | [디스크 트리(7432)](https://www.acmicpc.net/problem/7432) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/142 | | 7차시 | 2024.08.07.수 | 다익스트라 | [지형 이동(Lv.4)](https://school.programmers.co.kr/learn/courses/30/lessons/62050) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/144 | | 8차시 | 2024.08.19.월 | 이분 탐색 | [입국심사(Lv.3)](https://school.programmers.co.kr/learn/courses/30/lessons/43238) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/148 | -| 9차시 | 2024.08.27.화 | 수학 | [음식 평론가(1188)](https://www.acmicpc.net/problem/1188) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/150 | \ No newline at end of file +| 9차시 | 2024.08.27.화 | 수학 | [음식 평론가(1188)](https://www.acmicpc.net/problem/1188) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/150 | +| 10차시 | 2024.08.28.수 | 브루트포스 | [램프(1034)](https://www.acmicpc.net/problem/1034) | | \ No newline at end of file diff --git "a/jung0115/\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/Baekjoon_1034.kt" "b/jung0115/\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/Baekjoon_1034.kt" new file mode 100644 index 0000000..9a0d9f8 --- /dev/null +++ "b/jung0115/\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/Baekjoon_1034.kt" @@ -0,0 +1,49 @@ +// 10차시 2024.08.28.수 : 백준 - 램프(1034) +import java.io.BufferedReader +import java.io.InputStreamReader +import java.util.StringTokenizer +import kotlin.math.max + +fun main() { + // ✅ Input + val br = BufferedReader(InputStreamReader(System.`in`)) + var st = StringTokenizer(br.readLine()) + + val N = st.nextToken().toInt() + val M = st.nextToken().toInt() + + val lamp = mutableListOf() + for(i: Int in 1..N) { + lamp.add(br.readLine()) + } + + val K = br.readLine().toInt() + + var answer = 0 + for(i: Int in 0..N-1) { + // 꺼져있는 램프 수 + var zeroCount = 0 + for(j: Int in 0..M-1) { + if(lamp[i][j] == '0') zeroCount++ + } + + // 불이 다 켜진 행의 수 + var rowCount = 0 + if(zeroCount <= K && zeroCount % 2 == K % 2) { + for(j: Int in 0..N-1) { + var isEqual = true + for(k: Int in 0..M-1) { + if(lamp[i][k] != lamp[j][k]) { + isEqual = false + break + } + } + if(isEqual) rowCount++ + } + + answer = max(answer, rowCount) + } + } + + print(answer) +} \ No newline at end of file From 9f95455f51693f2ad54522b2a3f02c27ef1991d1 Mon Sep 17 00:00:00 2001 From: jung0115 Date: Thu, 29 Aug 2024 02:47:42 +0900 Subject: [PATCH 04/14] 2024-08-28 readme --- jung0115/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jung0115/README.md b/jung0115/README.md index 33a0b02..9ea9352 100644 --- a/jung0115/README.md +++ b/jung0115/README.md @@ -11,4 +11,4 @@ | 7차시 | 2024.08.07.수 | 다익스트라 | [지형 이동(Lv.4)](https://school.programmers.co.kr/learn/courses/30/lessons/62050) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/144 | | 8차시 | 2024.08.19.월 | 이분 탐색 | [입국심사(Lv.3)](https://school.programmers.co.kr/learn/courses/30/lessons/43238) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/148 | | 9차시 | 2024.08.27.화 | 수학 | [음식 평론가(1188)](https://www.acmicpc.net/problem/1188) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/150 | -| 10차시 | 2024.08.28.수 | 브루트포스 | [램프(1034)](https://www.acmicpc.net/problem/1034) | | \ No newline at end of file +| 10차시 | 2024.08.28.수 | 브루트포스 | [램프(1034)](https://www.acmicpc.net/problem/1034) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/151 | \ No newline at end of file From 7a1efde9aedd2c5c1bfa0514e38a42c891ed7a9f Mon Sep 17 00:00:00 2001 From: jung0115 Date: Wed, 4 Sep 2024 23:47:14 +0900 Subject: [PATCH 05/14] 2024-09-04 --- jung0115/README.md | 3 +- .../Baekjoon_1344.kt" | 37 ++++++++++++++++++ .../tempCodeRunnerFile.kt" | 39 +++++++++++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 "jung0115/\354\210\230\355\225\231/Baekjoon_1344.kt" create mode 100644 "jung0115/\354\210\230\355\225\231/tempCodeRunnerFile.kt" diff --git a/jung0115/README.md b/jung0115/README.md index 9ea9352..5e907f8 100644 --- a/jung0115/README.md +++ b/jung0115/README.md @@ -11,4 +11,5 @@ | 7차시 | 2024.08.07.수 | 다익스트라 | [지형 이동(Lv.4)](https://school.programmers.co.kr/learn/courses/30/lessons/62050) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/144 | | 8차시 | 2024.08.19.월 | 이분 탐색 | [입국심사(Lv.3)](https://school.programmers.co.kr/learn/courses/30/lessons/43238) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/148 | | 9차시 | 2024.08.27.화 | 수학 | [음식 평론가(1188)](https://www.acmicpc.net/problem/1188) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/150 | -| 10차시 | 2024.08.28.수 | 브루트포스 | [램프(1034)](https://www.acmicpc.net/problem/1034) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/151 | \ No newline at end of file +| 10차시 | 2024.08.28.수 | 브루트포스 | [램프(1034)](https://www.acmicpc.net/problem/1034) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/151 | +| 11차시 | 2024.09.04.수 | 수학 | [축구(1344)](https://www.acmicpc.net/problem/1344) | | \ No newline at end of file diff --git "a/jung0115/\354\210\230\355\225\231/Baekjoon_1344.kt" "b/jung0115/\354\210\230\355\225\231/Baekjoon_1344.kt" new file mode 100644 index 0000000..0f99fca --- /dev/null +++ "b/jung0115/\354\210\230\355\225\231/Baekjoon_1344.kt" @@ -0,0 +1,37 @@ +// 11차시 2024.09.04.수 : 백준 - 축구(1344) +import java.io.BufferedReader +import java.io.InputStreamReader +import kotlin.math.pow + +fun combination(n: Int, r: Int): Double { + var result = 1.0 + for (i in 0 until r) { + result *= (n - i).toDouble() + result /= (i + 1).toDouble() + } + return result +} + +fun probability(p: Double, k: Int): Double { + return combination(18, k) * p.pow(k) * (1 - p).pow(18 - k) +} + +fun main() { + // ✅ Input + val br = BufferedReader(InputStreamReader(System.`in`)) + + var A: Double = br.readLine().toDouble() / 100.0 + var B: Double = br.readLine().toDouble() / 100.0 + + val primeNumbers = setOf(2, 3, 5, 7, 11, 13, 17) + var nonPrimeA = 0.0 + var nonPrimeB = 0.0 + for (i in 0..18) { + if (i !in primeNumbers) { + nonPrimeA += probability(A, i) + nonPrimeB += probability(B, i) + } + } + + print(1 - (nonPrimeA * nonPrimeB)) +} \ No newline at end of file diff --git "a/jung0115/\354\210\230\355\225\231/tempCodeRunnerFile.kt" "b/jung0115/\354\210\230\355\225\231/tempCodeRunnerFile.kt" new file mode 100644 index 0000000..e0d2b19 --- /dev/null +++ "b/jung0115/\354\210\230\355\225\231/tempCodeRunnerFile.kt" @@ -0,0 +1,39 @@ +// 11차시 2024.09.04.수 : 백준 - 축구(1344) +import java.io.BufferedReader +import java.io.InputStreamReader +import kotlin.math.pow + +fun combination(n: Int, r: Int): Double { + var result = 1.0 + for (i in 0 until r) { + result *= (n - i).toDouble() + result /= (i + 1).toDouble() + } + return result +} + +fun probability(p: Double, k: Int): Double { + return combination(18, k) * p.pow(k) * (1 - p).pow(18 - k) +} + +fun main() { + // ✅ Input + val br = BufferedReader(InputStreamReader(System.`in`)) + + var A: Double = br.readLine().toDouble() / 100.0 + var B: Double = br.readLine().toDouble() / 100.0 + + // 2, 3, 5, 7, 11, 13, 17 + //val notPrimeNumber = listOf( 0, 1, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18 ) + val primeNumbers = setOf(2, 3, 5, 7, 11, 13, 17) + var nonPrimeA = 0.0 + var nonPrimeB = 0.0 + for (i in 0..18) { + if (i !in primeNumbers) { + nonPrimeA += probability(A, i) + nonPrimeB += probability(B, i) + } + } + + print(1 - (nonPrimeA * nonPrimeB)) +} \ No newline at end of file From 1c9fb409517a76fb4fa03c1d6bca3cf092fb9917 Mon Sep 17 00:00:00 2001 From: jung0115 Date: Wed, 4 Sep 2024 23:49:37 +0900 Subject: [PATCH 06/14] 2024-09-04 readme --- jung0115/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jung0115/README.md b/jung0115/README.md index 5e907f8..15a6d25 100644 --- a/jung0115/README.md +++ b/jung0115/README.md @@ -12,4 +12,4 @@ | 8차시 | 2024.08.19.월 | 이분 탐색 | [입국심사(Lv.3)](https://school.programmers.co.kr/learn/courses/30/lessons/43238) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/148 | | 9차시 | 2024.08.27.화 | 수학 | [음식 평론가(1188)](https://www.acmicpc.net/problem/1188) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/150 | | 10차시 | 2024.08.28.수 | 브루트포스 | [램프(1034)](https://www.acmicpc.net/problem/1034) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/151 | -| 11차시 | 2024.09.04.수 | 수학 | [축구(1344)](https://www.acmicpc.net/problem/1344) | | \ No newline at end of file +| 11차시 | 2024.09.04.수 | 수학 | [축구(1344)](https://www.acmicpc.net/problem/1344) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/153 | \ No newline at end of file From 571e7c6e8d8bf2d53bad17e722d3b9a91cf42f08 Mon Sep 17 00:00:00 2001 From: jung0115 Date: Sat, 7 Sep 2024 23:37:32 +0900 Subject: [PATCH 07/14] 2024-09-07 --- jung0115/README.md | 3 +- .../Baekjoon_1563.kt" | 37 ++++++++++++++++++ .../tempCodeRunnerFile.kt" | 39 ------------------- 3 files changed, 39 insertions(+), 40 deletions(-) create mode 100644 "jung0115/\353\213\244\354\235\264\353\202\230\353\257\271 \355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/Baekjoon_1563.kt" delete mode 100644 "jung0115/\354\210\230\355\225\231/tempCodeRunnerFile.kt" diff --git a/jung0115/README.md b/jung0115/README.md index 15a6d25..5e51741 100644 --- a/jung0115/README.md +++ b/jung0115/README.md @@ -12,4 +12,5 @@ | 8차시 | 2024.08.19.월 | 이분 탐색 | [입국심사(Lv.3)](https://school.programmers.co.kr/learn/courses/30/lessons/43238) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/148 | | 9차시 | 2024.08.27.화 | 수학 | [음식 평론가(1188)](https://www.acmicpc.net/problem/1188) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/150 | | 10차시 | 2024.08.28.수 | 브루트포스 | [램프(1034)](https://www.acmicpc.net/problem/1034) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/151 | -| 11차시 | 2024.09.04.수 | 수학 | [축구(1344)](https://www.acmicpc.net/problem/1344) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/153 | \ No newline at end of file +| 11차시 | 2024.09.04.수 | 수학 | [축구(1344)](https://www.acmicpc.net/problem/1344) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/153 | +| 12차시 | 2024.09.07.토 | 다이나믹 프로그래밍 | [개근상(1563)](https://www.acmicpc.net/problem/1563) | | \ No newline at end of file diff --git "a/jung0115/\353\213\244\354\235\264\353\202\230\353\257\271 \355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/Baekjoon_1563.kt" "b/jung0115/\353\213\244\354\235\264\353\202\230\353\257\271 \355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/Baekjoon_1563.kt" new file mode 100644 index 0000000..c1fe0b3 --- /dev/null +++ "b/jung0115/\353\213\244\354\235\264\353\202\230\353\257\271 \355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/Baekjoon_1563.kt" @@ -0,0 +1,37 @@ +// 12차시 2024.09.07.토 : 백준 - 개근상(1563) +import java.io.BufferedReader +import java.io.InputStreamReader + + +fun main() { + // ✅ Input + val br = BufferedReader(InputStreamReader(System.`in`)) + + val N = br.readLine().toInt() + + // ✅ Solve + // 출석 일수, 지각 일수, 연속 결석 일수 + val dp = Array(N + 1, {Array(2, {Array(3, {0})})}) + + dp[1][0][0] = 1 + dp[1][1][0] = 1 + dp[1][0][1] = 1 + + for(i: Int in 2..N) { + dp[i][0][0] = (dp[i-1][0][0] + dp[i-1][0][1] + dp[i-1][0][2]) % 1000000; + dp[i][0][1] = dp[i-1][0][0] % 1000000; + dp[i][0][2] = dp[i-1][0][1] % 1000000; + dp[i][1][0] = (dp[i][0][0] + dp[i-1][1][0] + dp[i-1][1][1] + dp[i-1][1][2]) % 1000000; + dp[i][1][1] = dp[i-1][1][0] % 1000000; + dp[i][1][2] = dp[i-1][1][1] % 1000000; + } + + var answer = 0 + for(i: Int in 0..1) { + for(j: Int in 0..2) { + answer += dp[N][i][j] + } + } + + print(answer) +} \ No newline at end of file diff --git "a/jung0115/\354\210\230\355\225\231/tempCodeRunnerFile.kt" "b/jung0115/\354\210\230\355\225\231/tempCodeRunnerFile.kt" deleted file mode 100644 index e0d2b19..0000000 --- "a/jung0115/\354\210\230\355\225\231/tempCodeRunnerFile.kt" +++ /dev/null @@ -1,39 +0,0 @@ -// 11차시 2024.09.04.수 : 백준 - 축구(1344) -import java.io.BufferedReader -import java.io.InputStreamReader -import kotlin.math.pow - -fun combination(n: Int, r: Int): Double { - var result = 1.0 - for (i in 0 until r) { - result *= (n - i).toDouble() - result /= (i + 1).toDouble() - } - return result -} - -fun probability(p: Double, k: Int): Double { - return combination(18, k) * p.pow(k) * (1 - p).pow(18 - k) -} - -fun main() { - // ✅ Input - val br = BufferedReader(InputStreamReader(System.`in`)) - - var A: Double = br.readLine().toDouble() / 100.0 - var B: Double = br.readLine().toDouble() / 100.0 - - // 2, 3, 5, 7, 11, 13, 17 - //val notPrimeNumber = listOf( 0, 1, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18 ) - val primeNumbers = setOf(2, 3, 5, 7, 11, 13, 17) - var nonPrimeA = 0.0 - var nonPrimeB = 0.0 - for (i in 0..18) { - if (i !in primeNumbers) { - nonPrimeA += probability(A, i) - nonPrimeB += probability(B, i) - } - } - - print(1 - (nonPrimeA * nonPrimeB)) -} \ No newline at end of file From 5bb54af98e5ebf3ed193cf13ffde75f9805c5f81 Mon Sep 17 00:00:00 2001 From: jung0115 Date: Sat, 7 Sep 2024 23:38:15 +0900 Subject: [PATCH 08/14] 2024-09-07 readme --- jung0115/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jung0115/README.md b/jung0115/README.md index 5e51741..2d2a0ce 100644 --- a/jung0115/README.md +++ b/jung0115/README.md @@ -13,4 +13,4 @@ | 9차시 | 2024.08.27.화 | 수학 | [음식 평론가(1188)](https://www.acmicpc.net/problem/1188) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/150 | | 10차시 | 2024.08.28.수 | 브루트포스 | [램프(1034)](https://www.acmicpc.net/problem/1034) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/151 | | 11차시 | 2024.09.04.수 | 수학 | [축구(1344)](https://www.acmicpc.net/problem/1344) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/153 | -| 12차시 | 2024.09.07.토 | 다이나믹 프로그래밍 | [개근상(1563)](https://www.acmicpc.net/problem/1563) | | \ No newline at end of file +| 12차시 | 2024.09.07.토 | 다이나믹 프로그래밍 | [개근상(1563)](https://www.acmicpc.net/problem/1563) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/157 | \ No newline at end of file From 73074dd03e06fd8e529c2ef2c92d09ed5227d6b1 Mon Sep 17 00:00:00 2001 From: jung0115 Date: Sat, 7 Sep 2024 23:40:28 +0900 Subject: [PATCH 09/14] 2024-09-07 update --- .../Baekjoon_1563.kt" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/jung0115/\353\213\244\354\235\264\353\202\230\353\257\271 \355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/Baekjoon_1563.kt" "b/jung0115/\353\213\244\354\235\264\353\202\230\353\257\271 \355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/Baekjoon_1563.kt" index c1fe0b3..e881ba8 100644 --- "a/jung0115/\353\213\244\354\235\264\353\202\230\353\257\271 \355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/Baekjoon_1563.kt" +++ "b/jung0115/\353\213\244\354\235\264\353\202\230\353\257\271 \355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/Baekjoon_1563.kt" @@ -33,5 +33,5 @@ fun main() { } } - print(answer) + print(answer % 1000000) } \ No newline at end of file From f8ed7aeb0b91a9742ebe4cf4ecfda00839955d08 Mon Sep 17 00:00:00 2001 From: jung0115 Date: Mon, 23 Sep 2024 21:41:54 +0900 Subject: [PATCH 10/14] 2024-09-23 --- jung0115/.gitignore | 3 +- jung0115/README.md | 3 +- .../Baekjoon_1256.java" | 55 +++++++++++++++++++ .../Baekjoon_1563.kt" | 0 .../Baekjoon_2624.kt" | 0 5 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 "jung0115/\353\213\244\354\235\264\353\202\230\353\257\271\355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/Baekjoon_1256.java" rename "jung0115/\353\213\244\354\235\264\353\202\230\353\257\271 \355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/Baekjoon_1563.kt" => "jung0115/\353\213\244\354\235\264\353\202\230\353\257\271\355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/Baekjoon_1563.kt" (100%) rename "jung0115/\353\213\244\354\235\264\353\202\230\353\257\271 \355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/Baekjoon_2624.kt" => "jung0115/\353\213\244\354\235\264\353\202\230\353\257\271\355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/Baekjoon_2624.kt" (100%) diff --git a/jung0115/.gitignore b/jung0115/.gitignore index 01345c6..64223e8 100644 --- a/jung0115/.gitignore +++ b/jung0115/.gitignore @@ -1,2 +1,3 @@ *.jars -*.jar \ No newline at end of file +*.jar +*.class \ No newline at end of file diff --git a/jung0115/README.md b/jung0115/README.md index 2d2a0ce..86e688b 100644 --- a/jung0115/README.md +++ b/jung0115/README.md @@ -13,4 +13,5 @@ | 9차시 | 2024.08.27.화 | 수학 | [음식 평론가(1188)](https://www.acmicpc.net/problem/1188) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/150 | | 10차시 | 2024.08.28.수 | 브루트포스 | [램프(1034)](https://www.acmicpc.net/problem/1034) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/151 | | 11차시 | 2024.09.04.수 | 수학 | [축구(1344)](https://www.acmicpc.net/problem/1344) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/153 | -| 12차시 | 2024.09.07.토 | 다이나믹 프로그래밍 | [개근상(1563)](https://www.acmicpc.net/problem/1563) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/157 | \ No newline at end of file +| 12차시 | 2024.09.07.토 | 다이나믹 프로그래밍 | [개근상(1563)](https://www.acmicpc.net/problem/1563) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/157 | +| 13차시 | 2024.09.23.월 | 다이나믹 프로그래밍 | [사전(1256)](https://www.acmicpc.net/problem/1256) | | \ No newline at end of file diff --git "a/jung0115/\353\213\244\354\235\264\353\202\230\353\257\271\355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/Baekjoon_1256.java" "b/jung0115/\353\213\244\354\235\264\353\202\230\353\257\271\355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/Baekjoon_1256.java" new file mode 100644 index 0000000..40dc87a --- /dev/null +++ "b/jung0115/\353\213\244\354\235\264\353\202\230\353\257\271\355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/Baekjoon_1256.java" @@ -0,0 +1,55 @@ +package jung0115.다이나믹프로그래밍; +// 13차시 2024.09.23.월 : 백준 - 사전(1256) + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Baekjoon_1256 { + public static void main(String[] args) throws IOException { + BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(bf.readLine()); + + int N = Integer.parseInt(st.nextToken()); // a의 개수 + int M = Integer.parseInt(st.nextToken()); // z의 개수 + int K = Integer.parseInt(st.nextToken()); // 몇 번째 문자열을 찾아야 하는지 + + StringBuilder answer = new StringBuilder(); + + long[][] dp = new long[ N + M + 1 ][ N + M + 1 ]; + dp[0][0] = 1; + + for(int i = 1;i <= N + M; i++){ + dp[i][0] = 1; + dp[i][i] = 1; + for(int j = 1; j < i; j++){ + dp[i][j] = dp[i-1][j-1] + dp[i-1][j]; + + if(dp[i][j] > 1000000000) + dp[i][j] = 1000000001; + } + } + + // 사전에 수록되어 있는 문자열의 개수가 K보다 작을 경우 + if(dp[N + M][N] < K) { + answer.append("-1"); + } + else { + while (N != 0 || M != 0) { + if(dp[N + M - 1][M] >= K) { + answer.append("a"); + N--; + } + else { + answer.append("z"); + K -= dp[N + M - 1][M]; + M--; + } + } + } + + System.out.print(answer); + + } +} diff --git "a/jung0115/\353\213\244\354\235\264\353\202\230\353\257\271 \355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/Baekjoon_1563.kt" "b/jung0115/\353\213\244\354\235\264\353\202\230\353\257\271\355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/Baekjoon_1563.kt" similarity index 100% rename from "jung0115/\353\213\244\354\235\264\353\202\230\353\257\271 \355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/Baekjoon_1563.kt" rename to "jung0115/\353\213\244\354\235\264\353\202\230\353\257\271\355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/Baekjoon_1563.kt" diff --git "a/jung0115/\353\213\244\354\235\264\353\202\230\353\257\271 \355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/Baekjoon_2624.kt" "b/jung0115/\353\213\244\354\235\264\353\202\230\353\257\271\355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/Baekjoon_2624.kt" similarity index 100% rename from "jung0115/\353\213\244\354\235\264\353\202\230\353\257\271 \355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/Baekjoon_2624.kt" rename to "jung0115/\353\213\244\354\235\264\353\202\230\353\257\271\355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/Baekjoon_2624.kt" From 9acd0df189043ee25a25576830541eb194daad8b Mon Sep 17 00:00:00 2001 From: jung0115 Date: Mon, 23 Sep 2024 21:45:08 +0900 Subject: [PATCH 11/14] 2024-09-23 readme --- jung0115/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jung0115/README.md b/jung0115/README.md index 86e688b..95433a2 100644 --- a/jung0115/README.md +++ b/jung0115/README.md @@ -14,4 +14,4 @@ | 10차시 | 2024.08.28.수 | 브루트포스 | [램프(1034)](https://www.acmicpc.net/problem/1034) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/151 | | 11차시 | 2024.09.04.수 | 수학 | [축구(1344)](https://www.acmicpc.net/problem/1344) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/153 | | 12차시 | 2024.09.07.토 | 다이나믹 프로그래밍 | [개근상(1563)](https://www.acmicpc.net/problem/1563) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/157 | -| 13차시 | 2024.09.23.월 | 다이나믹 프로그래밍 | [사전(1256)](https://www.acmicpc.net/problem/1256) | | \ No newline at end of file +| 13차시 | 2024.09.23.월 | 다이나믹 프로그래밍 | [사전(1256)](https://www.acmicpc.net/problem/1256) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/162 | \ No newline at end of file From 2a2871b15625198df78e74fc2542ce5c3dbcca57 Mon Sep 17 00:00:00 2001 From: jung0115 Date: Tue, 24 Sep 2024 11:04:56 +0900 Subject: [PATCH 12/14] 2024-09-23 update: --- .../Baekjoon_1256.java" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/jung0115/\353\213\244\354\235\264\353\202\230\353\257\271\355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/Baekjoon_1256.java" "b/jung0115/\353\213\244\354\235\264\353\202\230\353\257\271\355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/Baekjoon_1256.java" index 40dc87a..c091d09 100644 --- "a/jung0115/\353\213\244\354\235\264\353\202\230\353\257\271\355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/Baekjoon_1256.java" +++ "b/jung0115/\353\213\244\354\235\264\353\202\230\353\257\271\355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/Baekjoon_1256.java" @@ -32,7 +32,7 @@ public static void main(String[] args) throws IOException { } // 사전에 수록되어 있는 문자열의 개수가 K보다 작을 경우 - if(dp[N + M][N] < K) { + if(dp[N + M][M] < K) { answer.append("-1"); } else { From 90789664321baa0ec717ce717e03d0c98faccbea Mon Sep 17 00:00:00 2001 From: jung0115 Date: Thu, 26 Sep 2024 00:29:04 +0900 Subject: [PATCH 13/14] 2024-09-26 --- jung0115/README.md | 3 +- .../Baekjoon_1781.java" | 66 +++++++++++++++++++ .../Baekjoon_1781_fail.java" | 37 +++++++++++ 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 "jung0115/\352\267\270\353\246\254\353\224\224\354\225\214\352\263\240\353\246\254\354\246\230/Baekjoon_1781.java" create mode 100644 "jung0115/\352\267\270\353\246\254\353\224\224\354\225\214\352\263\240\353\246\254\354\246\230/Baekjoon_1781_fail.java" diff --git a/jung0115/README.md b/jung0115/README.md index 95433a2..cf0b919 100644 --- a/jung0115/README.md +++ b/jung0115/README.md @@ -14,4 +14,5 @@ | 10차시 | 2024.08.28.수 | 브루트포스 | [램프(1034)](https://www.acmicpc.net/problem/1034) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/151 | | 11차시 | 2024.09.04.수 | 수학 | [축구(1344)](https://www.acmicpc.net/problem/1344) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/153 | | 12차시 | 2024.09.07.토 | 다이나믹 프로그래밍 | [개근상(1563)](https://www.acmicpc.net/problem/1563) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/157 | -| 13차시 | 2024.09.23.월 | 다이나믹 프로그래밍 | [사전(1256)](https://www.acmicpc.net/problem/1256) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/162 | \ No newline at end of file +| 13차시 | 2024.09.23.월 | 다이나믹 프로그래밍 | [사전(1256)](https://www.acmicpc.net/problem/1256) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/162 | +| 14차시 | 2024.09.25.수 | 그리디 알고리즘 | [컵라면(1781)](https://www.acmicpc.net/problem/1781) | | \ No newline at end of file diff --git "a/jung0115/\352\267\270\353\246\254\353\224\224\354\225\214\352\263\240\353\246\254\354\246\230/Baekjoon_1781.java" "b/jung0115/\352\267\270\353\246\254\353\224\224\354\225\214\352\263\240\353\246\254\354\246\230/Baekjoon_1781.java" new file mode 100644 index 0000000..9444d35 --- /dev/null +++ "b/jung0115/\352\267\270\353\246\254\353\224\224\354\225\214\352\263\240\353\246\254\354\246\230/Baekjoon_1781.java" @@ -0,0 +1,66 @@ +// 14차시 2024.09.25.수 : 백준 - 컵라면(1781) +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; +import java.util.Arrays; +import java.util.PriorityQueue; + +public class Baekjoon_1781 { + static class CupNoodle implements Comparable { + int deadLine; + int count; + + public CupNoodle(int deadLine, int count) { + this.deadLine = deadLine; + this.count = count; + } + + @Override + public int compareTo(CupNoodle o) { + // 데드라인을 기준으로 오름차순 정렬 + return this.deadLine - o.deadLine; + } + } + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + int N = Integer.parseInt(br.readLine()); + + CupNoodle[] cupNoodles = new CupNoodle[N]; + + for (int i = 0; i < N; i++) { + StringTokenizer st = new StringTokenizer(br.readLine()); + + int deadLine = Integer.parseInt(st.nextToken()); // 데드라인 + int count = Integer.parseInt(st.nextToken()); // 맞힐 때 받는 컵라면 수 + + cupNoodles[i] = new CupNoodle(deadLine, count); + } + + // 데드라인을 기준으로 정렬 (오름차순) + Arrays.sort(cupNoodles); + + PriorityQueue pq = new PriorityQueue<>(); + + for (CupNoodle cn : cupNoodles) { + // 만약 현재 데드라인 내에 풀 수 있는 문제라면 큐에 추가 + pq.offer(cn.count); + + // 큐의 크기가 데드라인을 초과하면 가장 적은 컵라면 수를 제거 + if (pq.size() > cn.deadLine) { + pq.poll(); + } + } + + int answer = 0; + + // 큐에 남아 있는 컵라면의 총합을 구함 + while (!pq.isEmpty()) { + answer += pq.poll(); + } + + System.out.println(answer); + } +} diff --git "a/jung0115/\352\267\270\353\246\254\353\224\224\354\225\214\352\263\240\353\246\254\354\246\230/Baekjoon_1781_fail.java" "b/jung0115/\352\267\270\353\246\254\353\224\224\354\225\214\352\263\240\353\246\254\354\246\230/Baekjoon_1781_fail.java" new file mode 100644 index 0000000..95a5225 --- /dev/null +++ "b/jung0115/\352\267\270\353\246\254\353\224\224\354\225\214\352\263\240\353\246\254\354\246\230/Baekjoon_1781_fail.java" @@ -0,0 +1,37 @@ +// 14차시 2024.09.25.수 : 백준 - 컵라면(1781) +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; +import java.util.HashMap; +import java.util.Iterator; + +public class Baekjoon_1781_fail { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + int N = Integer.parseInt(br.readLine()); + + HashMap cupNoodles = new HashMap(); + + for(int i = 0; i < N; i++) { + StringTokenizer st = new StringTokenizer(br.readLine()); + + int deadLine = Integer.parseInt(st.nextToken()); // 데드라인 + int count = Integer.parseInt(st.nextToken()); // 맞힐 때 받는 컵라면 수 + + int current = cupNoodles.getOrDefault(deadLine, 0); + if(current < count) cupNoodles.put(deadLine, count); + } + + int answer = 0; + + Iterator keys = cupNoodles.keySet().iterator(); + while(keys.hasNext()){ + int key = keys.next(); + answer += cupNoodles.get(key); + } + + System.out.print(answer); + } +} From b2f729f6a8c7785420fc4c038ac6e6731c6c0f68 Mon Sep 17 00:00:00 2001 From: jung0115 Date: Thu, 26 Sep 2024 00:30:23 +0900 Subject: [PATCH 14/14] 2024-09-26 readme --- jung0115/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jung0115/README.md b/jung0115/README.md index cf0b919..d434c32 100644 --- a/jung0115/README.md +++ b/jung0115/README.md @@ -15,4 +15,4 @@ | 11차시 | 2024.09.04.수 | 수학 | [축구(1344)](https://www.acmicpc.net/problem/1344) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/153 | | 12차시 | 2024.09.07.토 | 다이나믹 프로그래밍 | [개근상(1563)](https://www.acmicpc.net/problem/1563) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/157 | | 13차시 | 2024.09.23.월 | 다이나믹 프로그래밍 | [사전(1256)](https://www.acmicpc.net/problem/1256) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/162 | -| 14차시 | 2024.09.25.수 | 그리디 알고리즘 | [컵라면(1781)](https://www.acmicpc.net/problem/1781) | | \ No newline at end of file +| 14차시 | 2024.09.25.수 | 그리디 알고리즘 | [컵라면(1781)](https://www.acmicpc.net/problem/1781) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/165 | \ No newline at end of file