본문 바로가기

Coding Test/백준

(78)
[백준/자바] 1541 - 잃어버린 괄호 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String str = sc.next(); String[] arr = str.split("-"); int result = 0; for (int i = 0; i < arr.length; i++) { if (i == 0) { result += sum(arr[i]); } else { result -= sum(arr[i]); } } System.out.println(result); } private static int sum(String s) { int sum = 0; String[] arr ..
[백준/자바] 1931 - 회의실 배정 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine..
[백준/자바] 1744 - 수 묶기 import java.util.Collections; import java.util.PriorityQueue; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); PriorityQueue plusPq = new PriorityQueue(Collections.reverseOrder()); PriorityQueue minusPq = new PriorityQueue(); int zero = 0; int one = 0; for (int i = 0; i < N; i++) { int num = sc.nextI..
[백준/자바] 1715 - 카드 정렬하기 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.PriorityQueue; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine()); PriorityQueue pq = new PriorityQueue(); for (int i = 0; i < N; i++) { pq.add(I..
[백준/자바] 11047 - 동전 0 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.nextToken()); int K = Integer.pa..
[백준/자바] 1300 - K번째 수 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int k = sc.nextInt(); long result = 0; long start = 1, end = k; while (start
[백준/자바] 2343 - 기타 레슨 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); int[] arr = new int[N]; int start = 0; int end = 0; for (int i = 0; i < N; i++) { arr[i] = sc.nextInt(); if (start < arr[i]) start = arr[i]; end += arr[i]; } while (start middle) { count++; sum = 0; } sum += arr[i]; } if (sum != 0..
[백준/자바] 1316 - 그룹 단어 체커 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int result = 0; for (int i = 0; i < N; i++) { char[] arr = sc.next().toCharArray(); int[] index = new int[26]; for (int j = 0; j < 26; j++) { index[j] = -1; } boolean isGroupWord = true; for (int k = 0; k < arr.length; k++) { if (index[arr[k] - 97] != ..