본문 바로가기
728x90
반응형

알고리즘문제풀이21

[Codility] Lesson16 - Greedy algorithms: Max Nonoverlapping Segments Problem Located on a line are N segments, numbered from 0 to N − 1, whose positions are given in arrays A and B. For each I (0 ≤ I < N) the position of segment I is from A[I] to B[I] (inclusive). The segments are sorted by their ends, which means that B[K] ≤ B[K + 1] for K such that 0 ≤ K < N − 1. Two segments I and J, such that I ≠ J, are overlapping if they share at least one common point. In .. 2021. 2. 10.
[Codility] Lesson12 - euclidean algorithm: Chocolates By Numbers Problem Two positive integers N and M are given. Integer N represents the number of chocolates arranged in a circle, numbered from 0 to N − 1. You start to eat the chocolates. After eating a chocolate you leave only a wrapper. You begin with eating chocolate number 0. Then you omit the next M − 1 chocolates or wrappers on the circle, and eat the following one. More precisely, if you ate chocolat.. 2021. 2. 8.
[Codility] Lesson10 - Prime and composite numbers: MinPerimeterRectangle Problem n integer N is given, representing the area of some rectangle. The area of a rectangle whose sides are of length A and B is A * B, and the perimeter is 2 * (A + B). The goal is to find the minimal perimeter of any rectangle whose area equals N. The sides of this rectangle should be only integers. For example, given integer N = 30, rectangles of area 30 are: (1, 30), with a perimeter of 6.. 2021. 1. 30.
[Atcoder] D - Friends (C++) Problem Problem Statement There are NN persons called Person 11 through Person NN. You are given MM facts that "Person AiAi and Person BiBi are friends." The same fact may be given multiple times. If XX and YY are friends, and YY and ZZ are friends, then XX and ZZ are also friends. There is no friendship that cannot be derived from the MM given facts. Takahashi the evil wants to divide the NN pe.. 2021. 1. 13.
728x90
반응형