728x90 백준149 [백준] 23336번 : A Sorting Problem(JAVA) https://www.acmicpc.net/problem/23336 23336번: A Sorting Problem You are given an array [p[1], p[2], ..., p[n]] where all the numbers in the array are distinct. In addition, the numbers are positive integers between 1 and n. You can only perform the following operations on the array: Pick two indices x and y such that | www.acmicpc.net 풀이 기본적인 2중 for문 버블정렬을 할 시 시간초과가 나온다. 분할정복으로 부분을 나눠서 체크해주면 된다... 2021. 10. 30. [백준] 23343번 : JavaScript(JAVA) https://www.acmicpc.net/problem/23343 23343번: JavaScript Print the result of the minus operation (x - y) on one Line. If the result is an integer, please print it without the decimal point. If the result is not a number, please print NaN. www.acmicpc.net 풀이 저는 try catch구문을 이용하여 풀었습니다. 물론 Matches랑 정규식을 이용해서 푸는 풀이랑 char형태로 isdigt를 이용한 풀이가 존재할 수도 있지만, 이게 편해서 이렇게 했습니다. 소스코드 import java.io.BufferedRe.. 2021. 10. 30. [백준] 1715번 : 카드 정렬하기(JAVA) https://www.acmicpc.net/problem/1715 1715번: 카드 정렬하기 정렬된 두 묶음의 숫자 카드가 있다고 하자. 각 묶음의 카드의 수를 A, B라 하면 보통 두 묶음을 합쳐서 하나로 만드는 데에는 A+B 번의 비교를 해야 한다. 이를테면, 20장의 숫자 카드 묶음과 30장 www.acmicpc.net 풀이 우선순위 큐를 이용하여 가장 작은 수 더한값을 answer에 더해주고 더한값을 우선순위큐에 넣는 방식으로 pq의 크기가 1이 될때까지 반복하시면 됩니다. 소스코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.PriorityQue.. 2021. 10. 29. [백준] 9063번 : 대지(JAVA) https://www.acmicpc.net/problem/9063 9063번: 대지 입력은 표준입력(standard input)을 통해 받아들인다. 입력의 첫 줄에는 테스트 케이스의 개수 T (1 ≤ T ≤ 20)가 주어진다. 각 테스트 케이스의 첫째 줄에는 점의 개수 N (1 ≤ N ≤ 100,000) 이 주어진다. www.acmicpc.net 풀이 풀이방식으로는 여러가지가 있습니다. 1. 1차원배열 2개를 만들어 정렬하고 (첫배열마지막 - 첫배열처음) * (둘배열마지막 - 둘배열처음) 2. max 2개, min 2개를 만들어 (max1 - min1) * (max2 - min2) 소스코드 1. import java.io.BufferedReader; import java.io.IOException; im.. 2021. 10. 27. 이전 1 ··· 14 15 16 17 18 19 20 ··· 38 다음 728x90