diff --git "a/LeeHyeonJin/BOJ/boj14226_\354\235\264\353\252\250\355\213\260\354\275\230.java" "b/LeeHyeonJin/BOJ/boj14226_\354\235\264\353\252\250\355\213\260\354\275\230.java" new file mode 100644 index 00000000..734f7732 --- /dev/null +++ "b/LeeHyeonJin/BOJ/boj14226_\354\235\264\353\252\250\355\213\260\354\275\230.java" @@ -0,0 +1,47 @@ +import java.io.*; +import java.util.*; + +public class boj14226_이모티콘 { + static int S; + + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + // input + S = Integer.parseInt(br.readLine()); + + // solution + int res = bfs(); + + // output + System.out.println(res); + } + + static int bfs() { + Queue queue = new ArrayDeque<>(); + int[][] dp = new int[2*S+1][S+1]; // 문자열길이, 클립보드길이 = 시간 + queue.offer(new int[] { 1,0,0 }); // 문자열길이, 클립보드길이, 시간 + for(int i=0; i<=S; i++) Arrays.fill(dp[i], Integer.MAX_VALUE); + + while(!queue.isEmpty()) { + int[] now = queue.poll(); + if(now[2] < dp[now[0]][now[1]]) { + dp[now[0]][now[1]] = now[2]; + queue.offer(new int[] { now[0],now[0],now[2]+1 }); + if(now[1] != 0) queue.offer(new int[] { now[0]+now[1],now[1],now[2]+1 }); + if(now[0]-1 > 0) queue.offer(new int[] { now[0]-1,now[1],now[2]+1 }); + } + } + + return getMin(dp); + } + + static int getMin(int[][] dp) { + int min = Integer.MAX_VALUE; + for(int time : dp[S]) { + min = Math.min(min, time); + } + return min; + } +} + diff --git "a/LeeHyeonJin/BOJ/boj23829_\354\235\270\353\254\270\354\230\210\354\210\240\355\203\220\354\202\254\354\243\274\352\260\204.java" "b/LeeHyeonJin/BOJ/boj23829_\354\235\270\353\254\270\354\230\210\354\210\240\355\203\220\354\202\254\354\243\274\352\260\204.java" new file mode 100644 index 00000000..35a71697 --- /dev/null +++ "b/LeeHyeonJin/BOJ/boj23829_\354\235\270\353\254\270\354\230\210\354\210\240\355\203\220\354\202\254\354\243\274\352\260\204.java" @@ -0,0 +1,62 @@ +import java.io.*; +import java.util.*; + +public class boj23829_인문예술탐사주간 { + static int N, Q; + static int[] p, x; + static long[] sumDistFromZero; + + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + // input + StringTokenizer st = new StringTokenizer(br.readLine(), " "); + N = Integer.parseInt(st.nextToken()); + Q = Integer.parseInt(st.nextToken()); + sumDistFromZero = new long[N+1]; + p = new int[N]; + x = new int[Q]; + + st = new StringTokenizer(br.readLine(), " "); + for(int i=0; i= target) { + right = mid; + } else { + left = mid+1; + } + } + return right; + } + + static long getSumDistBtw(int idx, int pic) { + if(pic > p[N-1]) { + return Math.abs(sumDistFromZero[N] - (long)pic *N); + } + int cntL = idx, cntR = N-idx; + long sum = 0; + sum += Math.abs(sumDistFromZero[idx] - (long)pic *cntL); + sum += sumDistFromZero[N] - sumDistFromZero[idx] - (long)pic *cntR; + return sum; + } +} diff --git "a/LeeHyeonJin/BOJ/boj25795_\354\230\210\354\201\234\354\264\210\354\275\234\353\246\277\352\263\274\354\210\253\354\236\220\353\206\200\354\235\264.java" "b/LeeHyeonJin/BOJ/boj25795_\354\230\210\354\201\234\354\264\210\354\275\234\353\246\277\352\263\274\354\210\253\354\236\220\353\206\200\354\235\264.java" new file mode 100644 index 00000000..14202af2 --- /dev/null +++ "b/LeeHyeonJin/BOJ/boj25795_\354\230\210\354\201\234\354\264\210\354\275\234\353\246\277\352\263\274\354\210\253\354\236\220\353\206\200\354\235\264.java" @@ -0,0 +1,51 @@ +import java.io.*; +import java.util.*; + +public class boj25795_예쁜초콜릿과숫자놀이 { + static int N, a, b, c; + static char[] chocolates; + static final int MOD = 100000, WHITE = 1, DARK = -1; + static long res = Integer.MIN_VALUE; + + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + // input + StringTokenizer st = new StringTokenizer(br.readLine(), " "); + N = Integer.parseInt(st.nextToken()); + a = Integer.parseInt(st.nextToken()); + b = Integer.parseInt(st.nextToken()); + c = Integer.parseInt(st.nextToken()); + + // solution + chocolates = new char[2*N]; + construct(0, N, 0); + + // output + System.out.println(res); + } + + static void construct(int prev, int cntW, int idx) { + if(idx == 2*N) { + res = Math.max(res, calc()); + return; + } + if(prev > 0) { + chocolates[idx] = 'D'; + construct(prev+DARK, cntW, idx+1); + } + if(cntW > 0) { + chocolates[idx] = 'W'; + construct(prev+WHITE, cntW-1, idx+1); + } + } + + static long calc() { + long sum = a; + for(char chocolate : chocolates) { + if(chocolate == 'W') sum = (sum+b)%MOD; + else sum = (sum*c)%MOD; + } + return sum; + } +}