Algorithm 28

[Algorithm/Baekjoon] 로봇 조종하기 - 2169 (G2/JAVA)

📑문제링크 2169번: 로봇 조종하기 💻코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int n = In..

Algorithm/Baekjoon 2023.06.23

[Algorithm/Baekjoon] 파티 - 1238 (G3/JAVA)

📑문제링크 1238번: 파티 💻코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { 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 = Inte..

Algorithm/Baekjoon 2023.06.22

[Algorithm/Baekjoon] 겹치는 건 싫어 - 20922 (S1/JAVA)

📑문제링크 20922번: 겹치는 건 싫어 💻코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { 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.nextT..

Algorithm/Baekjoon 2023.06.21

[Algorithm/Programmers] 콜라 문제 - 132267 (L1/JAVA)

📑문제링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 💻코드 class Solution { public int solution(int a, int b, int n) { int answer = 0; while(n >= a){ // 빈병 n개를 가져가서 받은 콜라의 수 answer += (n / a) * b; // 남은 빈병의 수 n = (n / a) * b + n % a; } return answer; } } ⏳회고 남은 빈병의 수를 먼저 계산하고 새로 받는 콜라의 수를 계산해서 틀렸었다. 주말 지나고 다시 난이도 있는 문제를 풀어야겠다. 피곤해도 차분..

[Algorithm/Programmers] 과일 장수 - 135808 (L1/JAVA)

📑문제링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 💻코드 import java.util.Arrays; import java.util.Collections; class Solution { public int solution(int k, int m, int[] score) { int answer = 0; // 방법1. 내림차순으로 정렬 // primitive Type을 Wrapper클래스로 박싱 Integer[] tmp = Arrays.stream(score).boxed().toArray(Integer[]::new); Arrays.sort(tmp,Co..

[Algorithm/Programmers] 로또의 최고 순위와 최저 순위 - 77484 (L1/JAVA)

📑문제링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 💻코드 class Solution { public int[] solution(int[] lottos, int[] win_nums) { int[] answer = new int[2]; int win_nums_counts = 0;//일치하는 번호의 수 int lottos_zero_counts = 0;//로또에서 알아볼 수 없는 번호의 수 for(int i = 0; i < 6; i++) { if(lottos[i] == 0){ lottos_zero_counts++; continue; } for(int j ..

[Algorithm/Baekjoon] 1의 개수 세기 - 9527 (G2/JAVA)

📑문제링크 9527번: 1의 개수 세기 💻코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { static long[] dp = new long[55]; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); l..

Algorithm/Baekjoon 2023.06.14