Skip to content
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

LAST COMMIT #335

Merged
merged 8 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions ChoiJunHo/BOJ/study29_1109/boj14226.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import java.io.*;
import java.util.*;

public class Main{
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StringBuilder sb = new StringBuilder();
static StringTokenizer st;

public static void main(String[] args) throws IOException {
int[] dist = new int[1000 + 1];
Arrays.fill(dist, Integer.MAX_VALUE);
dist[1] = 0;

Queue<Integer> queue = new ArrayDeque<Integer>();
queue.add(1);
while(!queue.isEmpty()){
int curr = queue.poll();

for(int mul = 2; mul * curr <= 1000; mul++){
if(dist[curr * mul] <= dist[curr] + mul) continue;
dist[curr * mul] = dist[curr] + mul;
queue.add(curr * mul);
}

for(int sub = 1; sub < curr; sub++){
if(dist[curr - sub] <= dist[curr] + sub) break;
dist[curr - sub] = dist[curr] + sub;
queue.add(curr - sub);
}
}
int S = Integer.parseInt(br.readLine());
System.out.println(dist[S]);
}
}
60 changes: 60 additions & 0 deletions ChoiJunHo/BOJ/study29_1109/boj17092.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import java.io.*;
import java.util.*;

public class Main{
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StringBuilder sb = new StringBuilder();
static StringTokenizer st;

public static void main(String[] args) throws IOException {
int[][] dx = {
{0, 0, 0, 1, 1, 1, 2, 2, 2},
{0, 0, 0, -1, -1, -1, 1, 1, 1},
{0, 0, 0, -1, -1, -1, -2, -2, -2}
};
int[][] dy = {
{1, 2, 0, 1, 2, 0, 1, 2, 0},
{-1, 0, 1, -1, 0, 1, -1, 0, 1},
{-2, -1, 0, -2, -1, 0, -2, -1, 0}
};
st = new StringTokenizer(br.readLine());
long H = Long.parseLong(st.nextToken());
long W = Long.parseLong(st.nextToken());
int N = Integer.parseInt(st.nextToken());

HashSet<Long> loc = new HashSet<Long>();
for(int i = 0; i < N; i++){
st = new StringTokenizer(br.readLine());
long x = Long.parseLong(st.nextToken()) - 1;
long y = Long.parseLong(st.nextToken()) - 1;
loc.add(x * W + y);
}

long[] cnt = new long[10];
for(long curr : loc){
long x = curr / W;
long y = curr % W;

for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
int count = 0;
boolean able = true;
for(int k = 0; k < 9; k++){
long tx = x + dx[i][k];
long ty = y + dy[j][k];
if(tx < 0 || ty < 0 || tx >= H || ty >= W){
able = false;
break;
}
if(loc.contains(tx * W + ty)) count++;
}
if(able) cnt[count]++;
}
}
}
cnt[0] = (H - 2) * (W - 2);
for(int i = 1; i < 10; i++) cnt[i] /= i;
for(int i = 1; i < 10; i++) cnt[0] -= cnt[i];
for(int i = 0; i < 10; i++) System.out.println(cnt[i]);
}
}
46 changes: 46 additions & 0 deletions ChoiJunHo/BOJ/study29_1109/boj23829.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import java.io.*;
import java.util.*;

public class Main{
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StringBuilder sb = new StringBuilder();
static StringTokenizer st;

public static void main(String[] args) throws IOException {
st = new StringTokenizer(br.readLine());
int N = Integer.parseInt(st.nextToken());
int Q = Integer.parseInt(st.nextToken());

long[] distance = new long[N];
long[] distanceSum = new long[N];
st = new StringTokenizer(br.readLine());
for(int i = 0; i < N; i++){
distance[i] = Long.parseLong(st.nextToken());
}
Arrays.sort(distance);
for(int i = 0; i < N; i++){
distanceSum[i] = distance[i] + (i > 0 ? distanceSum[i - 1] : 0);
}
for(int i = 0; i < Q; i++){
int low = 0;
int high = N - 1;
int x = Integer.parseInt(br.readLine());

int idx = N - 1;
while(low <= high){
int mid = (low + high) / 2;
if(distance[mid] <= x){
low = mid + 1;
idx = mid;
} else {
high = mid - 1;
}
}
long answer = 0;
answer += Math.abs(distanceSum[N - 1] - distanceSum[idx] - (long) x * (N - idx - 1));
answer += Math.abs((long) x * (idx + 1) - distanceSum[idx]);
sb.append(answer).append('\n');
}
System.out.println(sb);
}
}
48 changes: 48 additions & 0 deletions ChoiJunHo/BOJ/study30_1113/boj25195.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import java.io.*;
import java.util.*;

public class Main{
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StringBuilder sb = new StringBuilder();
static StringTokenizer st;

public static void main(String[] args) throws IOException {
st = new StringTokenizer(br.readLine());
int N = Integer.parseInt(st.nextToken());
int M = Integer.parseInt(st.nextToken());

HashMap<Integer, ArrayList<Integer>> edge = new HashMap<Integer, ArrayList<Integer>>();
for(int i = 0; i < M; i++){
st = new StringTokenizer(br.readLine());
int s = Integer.parseInt(st.nextToken());
int e = Integer.parseInt(st.nextToken());
if(!edge.containsKey(s)) edge.put(s, new ArrayList<Integer>());
edge.get(s).add(e);
}

int S = Integer.parseInt(br.readLine());
st = new StringTokenizer(br.readLine());
HashSet<Integer> fanclub = new HashSet<Integer>();
for(int i = 0; i < S; i++) fanclub.add(Integer.parseInt(st.nextToken()));


Queue<Integer> queue = new ArrayDeque<>();
if(!fanclub.contains(1)) queue.add(1);

boolean answer = false;
while(!queue.isEmpty()){
int curr = queue.poll();

if(edge.containsKey(curr)){
for(int next : edge.get(curr)){
if(fanclub.contains(next)) continue;
queue.add(next);
}
} else {
answer = true;
}
}

System.out.println(answer ? "yes" : "Yes");
}
}
29 changes: 29 additions & 0 deletions ChoiJunHo/BOJ/study30_1113/boj27896.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import java.io.*;
import java.util.*;

public class Main{
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StringBuilder sb = new StringBuilder();
static StringTokenizer st;

public static void main(String[] args) throws IOException {
st = new StringTokenizer(br.readLine());
int N = Integer.parseInt(st.nextToken());
int M = Integer.parseInt(st.nextToken());

PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
st = new StringTokenizer(br.readLine());
int satisfaction = 0;
int eggplant = 0;
for(int i = 0; i < N; i++) {
int x = Integer.parseInt(st.nextToken());
satisfaction += x;
pq.add(-x);
while(satisfaction >= M){
satisfaction -= -pq.poll() * 2;
eggplant++;
}
}
System.out.println(eggplant);
}
}
64 changes: 64 additions & 0 deletions ChoiJunHo/BOJ/study30_1113/boj28449.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import java.io.*;
import java.util.*;

public class Main{
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StringBuilder sb = new StringBuilder();
static StringTokenizer st;

public static void main(String[] args) throws IOException {
st = new StringTokenizer(br.readLine());

int N = Integer.parseInt(st.nextToken());
int M = Integer.parseInt(st.nextToken());

int[] a = new int[N];
int[] b = new int[M];

st = new StringTokenizer(br.readLine());
for(int i = 0; i < N; i++) a[i] = Integer.parseInt(st.nextToken());

st = new StringTokenizer(br.readLine());
for(int i = 0; i < M; i++) b[i] = Integer.parseInt(st.nextToken());

Arrays.sort(a);
Arrays.sort(b);

long win = 0, draw = 0, lose = 0;

for(int i = 0; i < N; i++){
int curr = a[i];

int low = 0;
int high = M - 1;

int upperbound = M;
while(low <= high){
int mid = (low + high) / 2;
if(curr < b[mid]){
high = mid - 1;
upperbound = mid;
} else {
low = mid + 1;
}
}

low = 0;
high = M - 1;
int lowerbound = -1;
while(low <= high){
int mid = (low + high) / 2;
if(curr <= b[mid]){
high = mid - 1;
} else {
low = mid + 1;
lowerbound = mid;
}
}
win += lowerbound + 1;
draw += upperbound - lowerbound - 1;
lose += M - upperbound;
}
System.out.print(win + " " + lose + " " + draw);
}
}
12 changes: 12 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,15 @@ PR Comment :
### 건의사항

`Discussions` 나 MM채널, 개인 MM을 이용한다.


---

### 결과


| 8월 | 9월 | 10월 |
| -------- | -------- | -------- |
| <img src="https://github.com/SSAFY-10th-Seoul17/algorithm_ssafy/blob/main/.docs/outcome/8월 우수 스터디.png" width="300"> | <img src="https://github.com/SSAFY-10th-Seoul17/algorithm_ssafy/blob/main/.docs/outcome/9월 우수 스터디.jpg" width="300"> | <img src="https://github.com/SSAFY-10th-Seoul17/algorithm_ssafy/blob/main/.docs/outcome/10월 우수 스터디.png" width="300"> |


Loading