본문 바로가기

휴지통665

백준 13305 import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; class Main13305 { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine()); StringTokenizer st = new StringTokenizer(br.readLine()); int[] distance = new int[N]; for (int i = 1; i < N;.. 2023. 7. 13.
백준 1343 import java.io.BufferedReader; import java.io.InputStreamReader; class Main1343 { //https://www.acmicpc.net/problem/1343 private static final String A = "AAAA"; private static final String B = "BB"; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String input = br.readLine(); while (input.contains("XXXX")) { inpu.. 2023. 7. 11.
백준 14916 import java.io.BufferedReader; import java.io.InputStreamReader; class Main14916 { //https://www.acmicpc.net/problem/14916 public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); if (n == 1 || n == 3) { System.out.println(-1); return; } int answer = n / 5; n %= 5; if (n % 2 != 0) .. 2023. 7. 11.
백준 2828 import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; class Main2828 { //https://www.acmicpc.net/problem/2828 public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int N = Integer.parseInt(st.nextToken()); int M = Inte.. 2023. 7. 11.
백준 2217 import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.List; class Main2217 { //https://www.acmicpc.net/problem/2217 public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine()); List ropes = new ArrayL.. 2023. 7. 11.
연속된 부분 수열의 합 package programmers; import java.util.Arrays; public class 연속된_부분_수열의_합 { public static int[] solution(int[] sequence, int k) { int[] answer = new int[2]; int[] partSum = init(sequence); int left = 0; int right = 0; int cur = Integer.MAX_VALUE; while (left 2023. 4. 8.