diff --git "a/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-16681] \353\223\261\354\202\260.md" "b/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-16681] \353\223\261\354\202\260.md" new file mode 100644 index 00000000..93161cc4 --- /dev/null +++ "b/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-16681] \353\223\261\354\202\260.md" @@ -0,0 +1,98 @@ +```java + +import java.util.*; +import java.io.*; + +public class Main { + + // IO field + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st = new StringTokenizer(""); + + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static String nextToken() throws Exception { + while(!st.hasMoreTokens()) nextLine(); + return st.nextToken(); + } + static int nextInt() throws Exception { return Integer.parseInt(nextToken()); } + static long nextLong() throws Exception { return Long.parseLong(nextToken()); } + static double nextDouble() throws Exception { return Double.parseDouble(nextToken()); } + static void bwEnd() throws Exception {bw.flush();bw.close();} + + // Additional field + + static final long INF = (long)1e18 + 7; + + static int N, M, D, E; + static List[] V; + static int[] H; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + N = nextInt(); + M = nextInt(); + D = nextInt(); + E = nextInt(); + + H = new int[N+1]; + for(int i=1;i<=N;i++) H[i] = nextInt(); + + V = new List[N+1]; + for(int i=1;i<=N;i++) V[i] = new ArrayList<>(); + for(int i=0;i Q = new PriorityQueue<>((a,b) -> Long.compare(a[0], b[0])); + Q.offer(new long[] {0,start}); + while(!Q.isEmpty()) { + long[] now = Q.poll(); + long d = now[0]; + int n = (int)now[1]; + if(d > X[n]) continue; + for(int[] e:V[n]) { + int i = e[0], c = e[1]; + if(X[i] > d+c && H[n] < H[i]) { + X[i] = d+c; + Q.offer(new long[] {X[i],i}); + } + } + } + return X; + } + +} + +``` diff --git "a/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-1800] \354\235\270\355\204\260\353\204\267 \354\204\244\354\271\230.md" "b/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-1800] \354\235\270\355\204\260\353\204\267 \354\204\244\354\271\230.md" new file mode 100644 index 00000000..f84bc98c --- /dev/null +++ "b/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-1800] \354\235\270\355\204\260\353\204\267 \354\204\244\354\271\230.md" @@ -0,0 +1,91 @@ +```java +import java.util.*; +import java.io.*; + +public class Main { + + // IO field + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st = new StringTokenizer(""); + + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static String nextToken() throws Exception { + while(!st.hasMoreTokens()) nextLine(); + return st.nextToken(); + } + static int nextInt() throws Exception { return Integer.parseInt(nextToken()); } + static long nextLong() throws Exception { return Long.parseLong(nextToken()); } + static double nextDouble() throws Exception { return Double.parseDouble(nextToken()); } + static void bwEnd() throws Exception {bw.flush();bw.close();} + + // Additional field + + static final int INF = (int)1e9 + 7; + + static int N, P, K; + static List[] V; + static int[][] D; + static PriorityQueue Q; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + N = nextInt(); + P = nextInt(); + K = nextInt(); + V = new List[N+1]; + for(int i=1;i<=N;i++) V[i] = new ArrayList<>(); + for(int i=0;i((a,b) -> a[0]-b[0]); + + } + + static void solve() throws Exception { + + D[N][0] = 0; + Q.offer(new int[] {0,N,0}); + int ans = INF; + while(!Q.isEmpty()) { + int[] now = Q.poll(); + int d = now[0], n = now[1], k = now[2]; + if(d > D[n][k]) continue; + if(n == 1) { + ans = Math.min(ans, d); + break; + } + for(int[] e:V[n]) { + int i = e[0], c = Math.max(d, e[1]); + // 안 쓰는 경우 + if(D[i][k] > c) { + D[i][k] = c; + Q.offer(new int[] {c,i,k}); + } + // 쓰는 경우 + if(k d) { + D[i][k+1] = d; + Q.offer(new int[] {d,i,k+1}); + } + } + } + bw.write((ans == INF ? -1 : ans) + "\n"); + + } + +} +``` diff --git "a/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-18119] \353\213\250\354\226\264 \354\225\224\352\270\260.md" "b/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-18119] \353\213\250\354\226\264 \354\225\224\352\270\260.md" new file mode 100644 index 00000000..aeca95ba --- /dev/null +++ "b/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-18119] \353\213\250\354\226\264 \354\225\224\352\270\260.md" @@ -0,0 +1,75 @@ +```java +import java.util.*; +import java.io.*; + +public class Main { + + // IO field + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st = new StringTokenizer(""); + + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static String nextToken() throws Exception { + while(!st.hasMoreTokens()) nextLine(); + return st.nextToken(); + } + static int nextInt() throws Exception { return Integer.parseInt(nextToken()); } + static long nextLong() throws Exception { return Long.parseLong(nextToken()); } + static double nextDouble() throws Exception { return Double.parseDouble(nextToken()); } + static void bwEnd() throws Exception {bw.flush();bw.close();} + + // Additional field + + static int N, M; + static int[] A, O; + static int[] T; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + N = nextInt(); + M = nextInt(); + A = new int[N]; + T = new int[135]; + int c = 0; + for(char i='a';i<='z';i++) { + if(i=='a' || i=='e' || i=='i' || i=='o' || i=='u') T[i] = -1; + else T[i] = c++; + } + + for(int i=0;i a[0]-b[0]); + int ans = 0, next = -1; + for(int i=0;i= e) continue; + next = Math.max(s, next); + int temp = (e-next-1)/L + 1; + ans += temp; + next += temp*L; + } + bw.write(ans + "\n"); + + } + +} + +``` diff --git "a/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-23743] \353\260\251\355\203\210\354\266\234.md" "b/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-23743] \353\260\251\355\203\210\354\266\234.md" new file mode 100644 index 00000000..01b3423f --- /dev/null +++ "b/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-23743] \353\260\251\355\203\210\354\266\234.md" @@ -0,0 +1,69 @@ +```java + +import java.util.*; +import java.io.*; + +public class Main { + + // IO field + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st = new StringTokenizer(""); + + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static String nextToken() throws Exception { + while(!st.hasMoreTokens()) nextLine(); + return st.nextToken(); + } + static int nextInt() throws Exception { return Integer.parseInt(nextToken()); } + static long nextLong() throws Exception { return Long.parseLong(nextToken()); } + static double nextDouble() throws Exception { return Double.parseDouble(nextToken()); } + static void bwEnd() throws Exception {bw.flush();bw.close();} + + // Additional field + + static int N, M; + static List E; + static int[] r; + + static int f(int x) {return x==r[x] ? x : (r[x]=f(r[x]));} + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + N = nextInt(); + M = nextInt(); + r = new int[N+1]; + for(int i=0;i<=N;i++) r[i] = i; + E = new ArrayList<>(); + while(M-->0) E.add(new int[] {nextInt(), nextInt(), nextInt()}); + for(int i=1;i<=N;i++) E.add(new int[] {0, i, nextInt()}); + + } + + static void solve() throws Exception { + + Collections.sort(E, (a,b) -> a[2]-b[2]); + int ans = 0; + for(int[] e:E) { + int a = e[0], b = e[1], c = e[2]; + int x = f(a), y = f(b); + if(x==y) continue; + r[x] = y; + ans += c; + } + bw.write(ans + "\n"); + + } + +} + +``` diff --git "a/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-3020] \352\260\234\353\230\245\353\262\214\353\240\210.md" "b/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-3020] \352\260\234\353\230\245\353\262\214\353\240\210.md" new file mode 100644 index 00000000..79237efc --- /dev/null +++ "b/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-3020] \352\260\234\353\230\245\353\262\214\353\240\210.md" @@ -0,0 +1,88 @@ +```java + +import java.util.*; +import java.io.*; + +public class Main { + + // IO field + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st = new StringTokenizer(""); + + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static String nextToken() throws Exception { + while(!st.hasMoreTokens()) nextLine(); + return st.nextToken(); + } + static int nextInt() throws Exception { return Integer.parseInt(nextToken()); } + static long nextLong() throws Exception { return Long.parseLong(nextToken()); } + static double nextDouble() throws Exception { return Double.parseDouble(nextToken()); } + static void bwEnd() throws Exception {bw.flush();bw.close();} + + // Additional field + + static int[] S; + static int N, H; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + N = nextInt(); + H = nextInt(); + S = new int[H+1]; + + } + + static void solve() throws Exception { + + PriorityQueue low = new PriorityQueue<>((a,b) -> Integer.compare(a, b)); + PriorityQueue high = new PriorityQueue<>((a,b) -> Integer.compare(b, a)); + for(int i=0;i0;i--) { + while(!high.isEmpty() && high.peek() == i) { + high.poll(); + cnt--; + } + S[i] += cnt; + } + + int min = Integer.MAX_VALUE; + cnt = 0; + for(int i=1;i<=H;i++) { + if(S[i] < min) { + min = S[i]; + cnt = 1; + } + else if(min == S[i]) cnt++; + } + bw.write(min + " " + cnt); + + } + +} + +```