diff --git "a/\352\266\214\355\230\201\354\244\200_14\354\243\274\354\260\250/[BOJ-1114] \355\206\265\353\202\230\353\254\264 \354\236\220\353\245\264\352\270\260.md" "b/\352\266\214\355\230\201\354\244\200_14\354\243\274\354\260\250/[BOJ-1114] \355\206\265\353\202\230\353\254\264 \354\236\220\353\245\264\352\270\260.md" new file mode 100644 index 00000000..987800a9 --- /dev/null +++ "b/\352\266\214\355\230\201\354\244\200_14\354\243\274\354\260\250/[BOJ-1114] \355\206\265\353\202\230\353\254\264 \354\236\220\353\245\264\352\270\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 int L, K, C; + static int[] A; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + L = nextInt(); + K = nextInt(); + C = nextInt(); + A = new int[K]; + for(int i=0;i>1; + for(int i=1;i m) { + max = Math.max(max, A[i-1]-prev); + prev = A[i-1]; + cnt++; + } + } + if(L - prev > m) { + max = Math.max(max, A[K-1]-prev); + prev = A[K-1]; + cnt++; + } + max = Math.max(max, L-prev); + if(cnt > C || max > m) s = m+1; + else e = m; + m = (s+e)>>1; + } + + int len = m; + + // i에서 처음 자르기 + for(int i=0;i len) { + max = Math.max(max, A[j-1]-prev); + prev = A[j-1]; + cnt++; + } + } + if(L - prev > len) { + max = Math.max(max, A[K-1]-prev); + prev = A[K-1]; + cnt++; + } + max = Math.max(max, L-prev); + if(cnt > C || max != len) continue; + bw.write(len + " " + A[i]); + return; + } + } + +} +``` diff --git "a/\352\266\214\355\230\201\354\244\200_14\354\243\274\354\260\250/[BOJ-12764] \354\213\270\354\247\200\353\260\251\354\227\220 \352\260\204 \354\244\200\355\225\230.md" "b/\352\266\214\355\230\201\354\244\200_14\354\243\274\354\260\250/[BOJ-12764] \354\213\270\354\247\200\353\260\251\354\227\220 \352\260\204 \354\244\200\355\225\230.md" new file mode 100644 index 00000000..a64211f5 --- /dev/null +++ "b/\352\266\214\355\230\201\354\244\200_14\354\243\274\354\260\250/[BOJ-12764] \354\213\270\354\247\200\353\260\251\354\227\220 \352\260\204 \354\244\200\355\225\230.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; + static TreeSet S; + static int[][] info; + static int[] num, cnt; + static int max = 0; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + N = nextInt(); + info = new int[N*2][2]; + for(int i=1;i<=N;i++) { + int p = nextInt(), q = nextInt(); + info[(i-1)*2] = new int[] {p,i}; + info[(i-1)*2+1] = new int[] {q,-i}; + } + S = new TreeSet<>(); + for(int i=1;i<=N;i++) S.add(i); + num = new int[N+1]; + cnt = new int[N+1]; + + } + + static void solve() throws Exception{ + + Arrays.sort(info, (a,b) -> a[0]-b[0]); + for(int[] e:info) { + int v = e[0], id = Math.abs(e[1]); + boolean out = e[1] < 0; + + if(out) S.add(num[id]); + else { + num[id] = S.pollFirst(); + max = Math.max(max, num[id]); + cnt[num[id]]++; + } + } + bw.write(max + "\n"); + for(int i=1;i<=max;i++) bw.write(cnt[i] + " "); + + } + +} +``` diff --git "a/\352\266\214\355\230\201\354\244\200_14\354\243\274\354\260\250/[BOJ-14391] \354\242\205\354\235\264 \354\241\260\352\260\201.md" "b/\352\266\214\355\230\201\354\244\200_14\354\243\274\354\260\250/[BOJ-14391] \354\242\205\354\235\264 \354\241\260\352\260\201.md" new file mode 100644 index 00000000..e29c0ea1 --- /dev/null +++ "b/\352\266\214\355\230\201\354\244\200_14\354\243\274\354\260\250/[BOJ-14391] \354\242\205\354\235\264 \354\241\260\352\260\201.md" @@ -0,0 +1,100 @@ +```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 char[][] A; + // 가로 : 1, 세로 : 2 + static int[][] used; + static int ans = 0; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + N = nextInt(); + M = nextInt(); + A = new char[N][M]; + for(int i=0;i0 && used[x][y-1] != 1)) { + String temp = ""; + int k = y; + for(;k0 && used[x-1][y] != 2)) { + String temp = ""; + int k = x; + for(;k Q = new PriorityQueue<>((a,b) -> a[0]==b[0] ? a[1]-b[1] : a[0]-b[0]); + int[][] D = new int[N][M]; + int[][] C = new int[N][M]; + for(int i=0;i=N || yy<0 || yy>=M) continue; + if(A[xx][yy] == 'F') { + bw.write(d + " "+ c); + return; + } + int dd = d + (A[xx][yy] == 'g' ? 1 : 0); + int cc = c + P[xx][yy]; + if(D[xx][yy] > dd || (D[xx][yy] == dd && C[xx][yy] > cc)) { + D[xx][yy] = dd; + C[xx][yy] = cc; + Q.offer(new int[] {dd,cc,xx,yy}); + } + } + } + + } + +} +``` diff --git "a/\352\266\214\355\230\201\354\244\200_14\354\243\274\354\260\250/[BOJ-1493] \353\260\225\354\212\244 \354\261\204\354\232\260\352\270\260.md" "b/\352\266\214\355\230\201\354\244\200_14\354\243\274\354\260\250/[BOJ-1493] \353\260\225\354\212\244 \354\261\204\354\232\260\352\270\260.md" new file mode 100644 index 00000000..30da2ff8 --- /dev/null +++ "b/\352\266\214\355\230\201\354\244\200_14\354\243\274\354\260\250/[BOJ-1493] \353\260\225\354\212\244 \354\261\204\354\232\260\352\270\260.md" @@ -0,0 +1,90 @@ +```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 long length, width, height; + static int N; + static long[] C; + static boolean impossible = false; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + length = nextInt(); + width = nextInt(); + height = nextInt(); + N = nextInt(); + C = new long[20]; + for(int i=0;i=0;k--) { + long d = 1< Q = new LinkedList<>(); + boolean[][][] vis = new boolean[8][8][9]; + Q.offer(new int[] {7,0,0}); + vis[7][0][0] = true; + while(!Q.isEmpty()) { + int[] now = Q.poll(); + int x = now[0], y = now[1], t = now[2]; + if(x==0 && y==7) { + bw.write("1"); + return; + } + for(int i=0;i<9;i++) { + int xx = x+dx[i], yy = y+dy[i], tt = Math.min(8, t+1); + if(xx<0 || xx>=8 || yy<0 || yy>=8) continue; + if(A[t][xx][yy]=='#' || A[tt][xx][yy]=='#' || vis[xx][yy][tt]) continue; + vis[xx][yy][tt] = true; + Q.offer(new int[] {xx,yy,tt}); + } + } + bw.write("0"); + + } + +} +``` diff --git "a/\352\266\214\355\230\201\354\244\200_14\354\243\274\354\260\250/[BOJ-1695] \355\214\260\353\246\260\353\223\234\353\241\254 \353\247\214\353\223\244\352\270\260.md" "b/\352\266\214\355\230\201\354\244\200_14\354\243\274\354\260\250/[BOJ-1695] \355\214\260\353\246\260\353\223\234\353\241\254 \353\247\214\353\223\244\352\270\260.md" new file mode 100644 index 00000000..84140e09 --- /dev/null +++ "b/\352\266\214\355\230\201\354\244\200_14\354\243\274\354\260\250/[BOJ-1695] \355\214\260\353\246\260\353\223\234\353\241\254 \353\247\214\353\223\244\352\270\260.md" @@ -0,0 +1,58 @@ +```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; + static int[] A; + static int[][] dp; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + N = nextInt(); + A = new int[N]; + for(int i=0;i