-
Notifications
You must be signed in to change notification settings - Fork 4
[6주차] 이지영 #79
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
Merged
[6주차] 이지영 #79
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7eccea3
이지영: [CT] 테트리스 블럭 안의 합 최대화 하기_241014
yeongleej eff4a95
이지영: [BOJ] 2805 나무 자르기_241015
yeongleej 98a4ede
이지영: [BOJ] 2110 공유기 설치_241015
yeongleej 92c2344
이지영: [BOJ] 7579 앱_241016
yeongleej 9f0ae35
이지영: [BOJ] 9084 동전_241016
yeongleej 7627188
이지영: [PG] 43238 입국심사_241017
yeongleej 6356a27
이지영: [SQL] 대장균들의 자식의 수 구하기_241015
yeongleej 4d78dde
이지영: [SQL] 재구매가 일어난 상품과 회원 리스트 구하기_241017
yeongleej a4bb43b
이지영: [SQL] 주문량이 많은 아이스크림들 조회하기_241017
yeongleej 92855e8
이지영: [PG] 42861 섬 연결하기_241018
yeongleej 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
55 changes: 55 additions & 0 deletions
BOJ/1000-5000번/JY_2110.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,55 @@ | ||
package day1015; | ||
|
||
import java.util.*; | ||
import java.io.*; | ||
|
||
public class JY_2110 { | ||
|
||
static int N, C; | ||
static long[] wrr; | ||
|
||
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()); | ||
C = Integer.parseInt(st.nextToken()); | ||
|
||
wrr = new long[N]; | ||
for(int i=0; i<N; i++) { | ||
wrr[i] = Long.parseLong(br.readLine()); | ||
} | ||
|
||
// 집위치 정렬 | ||
Arrays.sort(wrr); | ||
|
||
long s = 0; | ||
long e = (wrr[N-1] - wrr[0]); | ||
while(s < e) { | ||
// 인접한 두 공유기 사이의 거리 | ||
long mid = (s + e) / 2; | ||
|
||
long nextPos = 0; | ||
int cnt = 0; | ||
for(int i=0; i<N; i++) { | ||
// 공유기 새로 설치해야 함 | ||
if(wrr[i] >= nextPos) { | ||
nextPos = wrr[i] + mid; | ||
cnt++; | ||
} | ||
yeahdy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
// 필요한 공유기수가 더 많거나 같으면 거리를 늘릴 수 있음 | ||
if(cnt >= C) { | ||
s = mid + 1; | ||
} | ||
// 필요한 공유기수가 더 작으면 거리를 좁혀야 함 | ||
else { | ||
e = mid; | ||
} | ||
} | ||
|
||
System.out.println(e); | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
BOJ/1000-5000번/JY_2805.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,48 @@ | ||
package day1015; | ||
|
||
import java.util.*; | ||
import java.io.*; | ||
|
||
public class JY_2805 { | ||
|
||
public static void main(String[] args) throws IOException { | ||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
StringTokenizer st = new StringTokenizer(br.readLine()); | ||
|
||
int N = Integer.parseInt(st.nextToken()); | ||
int M = Integer.parseInt(st.nextToken()); | ||
|
||
int[] trr = new int[N]; | ||
int maxH = Integer.MIN_VALUE; | ||
st = new StringTokenizer(br.readLine()); | ||
for(int i=0; i<N; i++) { | ||
trr[i] = Integer.parseInt(st.nextToken()); | ||
maxH = Math.max(maxH, trr[i]); | ||
yeahdy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
|
||
int s = 0; | ||
int e = maxH; | ||
int ans = 0; | ||
while(s <= e) { | ||
KodaHye marked this conversation as resolved.
Show resolved
Hide resolved
|
||
int mid = (s + e) / 2; | ||
|
||
long total = 0; | ||
for(int i=0; i<N; i++) { | ||
if(trr[i] > mid) total += (trr[i]-mid); | ||
} | ||
|
||
// 자른길이가 M보다 작다면 높이를 더 낮게 설정해서 자른길이의 합을 늘려야 함 | ||
if(total < M) { | ||
e = mid - 1; | ||
} else { | ||
ans = mid; | ||
s = mid + 1; | ||
} | ||
} | ||
|
||
System.out.println(ans); | ||
|
||
} | ||
|
||
} |
81 changes: 81 additions & 0 deletions
CodeTree/2017-2018년/JY_테트리스_블럭_안의_합_최대화_하기.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,81 @@ | ||
package day1014; | ||
|
||
import java.util.*; | ||
import java.io.*; | ||
|
||
public class JY_테트리스_블럭_안의_합_최대화_하기 { | ||
|
||
static int N, M; | ||
static int[][] g; | ||
static boolean[][] visited; | ||
static int ans; | ||
// 현재 그래프 값 중 가장 큰 것 | ||
static int maxValue; | ||
static int[] dx = {0, 0, -1, 1}; | ||
static int[] dy = {-1, 1, 0, 0}; | ||
|
||
|
||
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()); | ||
M = Integer.parseInt(st.nextToken()); | ||
|
||
g = new int[N][M]; | ||
maxValue = Integer.MIN_VALUE; | ||
for(int i=0; i<N; i++) { | ||
st = new StringTokenizer(br.readLine()); | ||
for(int j=0; j<M; j++) { | ||
g[i][j] = Integer.parseInt(st.nextToken()); | ||
maxValue = Math.max(maxValue, g[i][j]); | ||
} | ||
} | ||
|
||
visited = new boolean[N][M]; | ||
ans = Integer.MIN_VALUE; | ||
for(int i=0; i<N; i++) { | ||
for(int j=0; j<M; j++) { | ||
visited[i][j] = true; | ||
dfs(i, j, 1, g[i][j]); | ||
visited[i][j] = false; | ||
} | ||
} | ||
|
||
System.out.println(ans); | ||
|
||
} | ||
public static boolean inRange(int x, int y) { | ||
return x>=0 && x<N && y>=0 && y<M; | ||
} | ||
public static void dfs(int x, int y, int depth, int total) { | ||
// 4개의 블록 모두 탐색 | ||
if(depth == 4) { | ||
ans = Math.max(ans, total); | ||
return; | ||
} | ||
// 가지치기 | ||
// 현재까지 탐색한 결과에 앞으로 최댓값만 추가한다고 해도 ans값보다 작으면 탐색X | ||
if(ans >= total+maxValue*(4-depth)) return; | ||
|
||
for(int i=0; i<4; i++) { | ||
int nx = x + dx[i]; | ||
int ny = y + dy[i]; | ||
if(!inRange(nx, ny)) continue; | ||
if(visited[nx][ny]) continue; | ||
// 2번째 블럭인 경우, ᅡ ᅥ ᅩ ᅮ 처럼 2번째 블록에서 연결된 2개의 블록을 찾아야한다. | ||
if(depth == 2) { | ||
visited[nx][ny] = true; | ||
dfs(x, y, depth+1, total+g[nx][ny]); | ||
visited[nx][ny] = false; | ||
} | ||
|
||
// 2번쨰 블록 이외에는 일반탐색 | ||
visited[nx][ny] = true; | ||
dfs(nx, ny, depth+1, total+g[nx][ny]); | ||
visited[nx][ny] = false; | ||
|
||
} | ||
} | ||
|
||
} |
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.