본문 바로가기

Algorithm37

백준 11663번 : 선분 위의 점 링크 : https://www.acmicpc.net/problem/11663 11663번: 선분 위의 점 첫째 줄에 점의 개수 N과 선분의 개수 M이 주어진다. (1 ≤ N, M ≤ 100,000) 둘째 줄에는 점의 좌표가 주어진다. 두 점이 같은 좌표를 가지는 경우는 없다. 셋째 줄부터 M개의 줄에는 선분의 시작점과 www.acmicpc.net import sys input = sys.stdin.readline from bisect import bisect_left, bisect_right N, M = map(int, input().split()) point = list(map(int, input().split())) point.sort() line = [list(map(int, input().spli.. 2022. 2. 12.
백준 2805번 : 나무 자르기 링크 : https://www.acmicpc.net/problem/2805 2805번: 나무 자르기 첫째 줄에 나무의 수 N과 상근이가 집으로 가져가려고 하는 나무의 길이 M이 주어진다. (1 ≤ N ≤ 1,000,000, 1 ≤ M ≤ 2,000,000,000) 둘째 줄에는 나무의 높이가 주어진다. 나무의 높이의 합은 항상 M보 www.acmicpc.net import sys input = sys.stdin.readline N, M = map(int, input().split()) height = list(map(int, input().split())) s, e = 1, max(height) while e-s >=0: mid = (s+e)//2 tree = 0 for i in height: tree +.. 2022. 2. 12.
백준 2512번 : 예산 링크 : https://www.acmicpc.net/problem/2512 2512번: 예산 첫째 줄에는 지방의 수를 의미하는 정수 N이 주어진다. N은 3 이상 10,000 이하이다. 다음 줄에는 각 지방의 예산요청을 표현하는 N개의 정수가 빈칸을 사이에 두고 주어진다. 이 값들은 모두 1 이상 www.acmicpc.net import sys input = sys.stdin.readline N = int(input()) bud = list(map(int, input().split())) M = int(input()) s, e = 0, max(bud) while e-s >= 0: mid = (s+e)//2 res = 0 for i in range(N): if bud[i] >= mid: res += mid.. 2022. 2. 12.
백준 2022번 : 사다리 링크 : https://www.acmicpc.net/problem/2022 2022번: 사다리 첫째 줄에 차례대로 x, y, c에 해당하는 양의 실수 세 개가 입력된다. 수는 소수점 여섯째 자리까지 주어질 수 있으며, 3,000,000,000보다 작거나 같다. www.acmicpc.net import sys input = sys.stdin.readline import math def get_height(x, y, w): h1 = math.sqrt(x**2-w**2) h2 = math.sqrt(y**2-w**2) h = h1*h2/(h1+h2) return h x, y, c = map(float, input().split()) w_s = 0 w_e = min(x, y) dif = 1 res_w = 0 wh.. 2022. 2. 12.