-
Notifications
You must be signed in to change notification settings - Fork 4
[14주차] 배수빈 #193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
[14주차] 배수빈 #193
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ae257ef
배수빈: [BOJ] 22944 죽음의 비_241220
baexxbin 688297c
배수빈: [SQL] Product Price at a Given Date_241210
baexxbin d07ca81
배수빈: [BOJ] 20291 파일 정리_241211
baexxbin 037b375
배수빈: [SQL] Investments in 2016_241212
baexxbin 8fd8c1b
배수빈: [PG] 340211 충돌 위험 찾기_241214
baexxbin d23c289
배수빈: [PG] 118669 등산코스 정하기_241214
baexxbin b6eedde
배수빈: [BOJ] 20181 꿈틀꿈틀 호석 애벌레 - 효율성_241214
baexxbin 0134758
배수빈: [CT] 색깔폭탄_241214
baexxbin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
BOJ/20001-25000번/SB_20181.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
import java.util.Arrays; | ||
import java.util.StringTokenizer; | ||
|
||
public class SB_20181 { | ||
static int N, K; | ||
static int[] arr; | ||
public static void main(String[] args) throws IOException { | ||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
StringTokenizer st = new StringTokenizer(br.readLine()); | ||
|
||
N = Integer.parseInt(st.nextToken()); | ||
K = Integer.parseInt(st.nextToken()); | ||
|
||
arr = new int[N]; | ||
st = new StringTokenizer(br.readLine()); | ||
for (int i = 0; i < N; i++) { | ||
arr[i] = Integer.parseInt(st.nextToken()); | ||
} | ||
|
||
long[] dp = new long[N + 1]; | ||
|
||
long happy = 0; | ||
int left = 0; | ||
for (int right = 0; right < N; right++) { | ||
happy += arr[right]; | ||
|
||
while (happy >= K) { | ||
dp[right + 1] = Math.max(dp[right + 1], dp[left] + happy - K); // dp[left]는 이전 구간의 최대값(이전 최종 right의 위치) | ||
happy -= arr[left++]; | ||
} | ||
|
||
dp[right + 1] = Math.max(dp[right], dp[right + 1]); // 현재까지의 최대값과 갱신된 최대값 비교 | ||
} | ||
|
||
System.out.println(Arrays.toString(dp)); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
BOJ/20001-25000번/SB_20291.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
import java.util.Map; | ||
import java.util.StringTokenizer; | ||
import java.util.TreeMap; | ||
|
||
public class SB_20291 { | ||
public static void main(String[] args) throws IOException { | ||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
StringTokenizer st; | ||
StringBuilder sb = new StringBuilder(); | ||
int N = Integer.parseInt(br.readLine()); | ||
|
||
TreeMap<String, Integer> map = new TreeMap<>(); | ||
for (int i = 0; i < N; i++) { | ||
st = new StringTokenizer(br.readLine(), "."); | ||
String name = st.nextToken(); | ||
String ext = st.nextToken(); | ||
map.put(ext, map.getOrDefault(ext, 0) + 1); | ||
} | ||
|
||
for (Map.Entry<String, Integer> entry : map.entrySet()) { | ||
sb.append(entry.getKey()).append(" ").append(entry.getValue()).append('\n'); | ||
} | ||
System.out.println(sb); | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
BOJ/20001-25000번/SB_22944.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package bfs; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
import java.util.*; | ||
|
||
public class SB_22944 { | ||
static int N, H, D; | ||
static int K = 0; | ||
static char[][] board; | ||
static Node start; | ||
static int[] dx = {-1, 1, 0, 0}; | ||
static int[] dy = {0, 0, -1, 1}; | ||
|
||
private static int bfs() { | ||
Queue<Node> que = new ArrayDeque<>(); | ||
int[][][] visited = new int[N][N][K + 1]; | ||
for (int[][] box : visited){ | ||
for (int[] row : box){ | ||
Arrays.fill(row, -1); | ||
} | ||
} | ||
que.offer(new Node(start.x, start.y, start.h, start.u, start.cntU)); | ||
visited[start.x][start.y][0] = 0; | ||
|
||
while (!que.isEmpty()) { | ||
Node cur = que.poll(); | ||
if (cur.h==0) continue; // 체력 0이면 죽음 | ||
if (board[cur.x][cur.y]=='E') { // 도착하면 탈출 | ||
return visited[cur.x][cur.y][cur.cntU]; | ||
} | ||
|
||
for (int i = 0; i < 4; i++) { | ||
int nx = cur.x + dx[i]; | ||
int ny = cur.y + dy[i]; | ||
if (!isValid(nx, ny) || visited[nx][ny][cur.cntU]!=-1) continue; | ||
if (board[nx][ny] == 'U') { | ||
if (cur.cntU + 1 <= K && visited[nx][ny][cur.cntU + 1] == -1) { // 우산 안넘치게 조건걸기 | ||
que.add(new Node(nx, ny, cur.h, D, cur.cntU + 1)); | ||
visited[nx][ny][cur.cntU+1] = visited[cur.x][cur.y][cur.cntU] + 1; | ||
} | ||
} | ||
else { | ||
if (cur.u > 0) que.add(new Node(nx, ny, cur.h, cur.u - 1, cur.cntU)); | ||
else que.add(new Node(nx, ny, cur.h-1, cur.u, cur.cntU)); | ||
visited[nx][ny][cur.cntU] = visited[cur.x][cur.y][cur.cntU] + 1; | ||
} | ||
} | ||
} | ||
return -1; | ||
} | ||
|
||
private static boolean isValid(int x, int y) { | ||
return 0 <= x && x < N && 0 <= y && y < N; | ||
} | ||
public static void main(String[] args) throws IOException { | ||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
StringTokenizer st = new StringTokenizer(br.readLine()); | ||
|
||
N = Integer.parseInt(st.nextToken()); | ||
H = Integer.parseInt(st.nextToken()); | ||
D = Integer.parseInt(st.nextToken()); | ||
|
||
board = new char[N][N]; | ||
for (int i = 0; i < N; i++) { | ||
String line = br.readLine(); | ||
for (int j = 0; j < N; j++) { | ||
board[i][j] = line.charAt(j); | ||
if (board[i][j]=='S') start = new Node(i, j, H, 0, 0); | ||
if (board[i][j]=='U') K++; | ||
} | ||
} | ||
|
||
System.out.println(bfs()); | ||
} | ||
|
||
static class Node{ | ||
int x, y, h, u; | ||
int cntU; // 우산 주운 개수 | ||
|
||
public Node(int x, int y, int h, int u, int cntU) { | ||
this.x = x; | ||
this.y = y; | ||
this.h = h; | ||
this.u = u; | ||
this.cntU = cntU; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.