본문 바로가기

PS/백준14

[백준] 구간 나누기2 - Python 13397 # 8 3# 1 5 4 6 2 1 3 7# [1, 1, 2, 3, 4, 5, 6, 7]import sysinput = sys.stdin.readlinedef check(target): global arr, M now_min = now_max = arr[0] count = 1 for i in range(len(arr)): now_min = min(now_min, arr[i]) now_max = max(now_max, arr[i]) if now_max - now_min > target: count += 1 now_max = now_min = arr[i] # print("count", count, targe.. 2024. 5. 19.
[백준] 같이 눈사람 만들래? - Python 20366 # 5# 3 5 2 5 9## 2 3 5 5 9#import sysinput = sys.stdin.readlineT = int(input().rstrip())nums = list(map(int, input().split()))nums.sort()result = sys.maxsizefor i in range(len(nums)): for j in range(i + 3, len(nums)): l = i + 1 r = j - 1 while l abs(temp): result = abs(temp) if temp 2024. 5. 15.
[백준] 말이 되고픈 원숭이 - Java 1600 import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.LinkedList;import java.util.Queue;import java.util.StringTokenizer;public class Main { /** * 입력) * 1 * 4 4 * 0 0 0 0 * 1 0 0 0 * 0 0 1 0 * 0 1 0 0 * * 출력) * 4 */ static int N; static int M; static int K; static int[][] grid; stat.. 2024. 5. 14.
[백준] 중량제한 - Java 1939 import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.ArrayList;import java.util.List;import java.util.StringTokenizer;public class BOJ1939 { /** * N(2 ≤ N ≤ 10,000)개의 섬으로 이루어진 나라가 있다. * 서로 같은 두 섬 사이에 여러 개의 다리가 있을 수도 있으며, 모든 다리는 양방향이다. * 한 번의 이동에서 옮길 수 있는 물품들의 중량의 최댓값을 구하는 프로그램을 작성하시오. * 첫째 줄에 N, M(1 ≤ M ≤ 100,000)이 주어진다. .. 2024. 5. 11.