목록그리디 (88)
넘치게 채우기
https://www.acmicpc.net/problem/2887BOJ - 행성 터널문제 유형: MST(최소 신장 트리), 최단 경로, 그래프, 정렬, 이진 탐색문제 난이도: Platinum V시간 제한: 1초메모리 제한: 128MB 문제때는 2040년, 이민혁은 우주에 자신만의 왕국을 만들었다. 왕국은 N개의 행성으로 이루어져 있다. 민혁이는 이 행성을 효율적으로 지배하기 위해서 행성을 연결하는 터널을 만들려고 한다.행성은 3차원 좌표위의 한 점으로 생각하면 된다. 두 행성 A(xA, yA, zA)와 B(xB, yB, zB)를 터널로 연결할 때 드는 비용은 min(|xA-xB|, |yA-yB|, |zA-zB|)이다.민혁이는 터널을 총 N-1개 건설해서 모든 행성이 서로 연결되게 하려고 한다. 이때, 모..
https://codeforces.com/contest/2063/problem/DCodeforces Round 1000(Div. 2) - D. Game With Triangles문제 유형: 그리디, 수학, 기하학, 삼분 탐색, 구현, 투 포인터, 브루트 포스, 부분합, 구간합시간 제한: 2초메모리 제한: 256MB 문제There are n+m">n+m distinct points (a1,0),(a2,0),…,(an,0),(b1,2),(b2,2),…,(bm,2)">(a1,0),(a2,0),…,(an,0),(b1,2),(b2,2),…,(bm,2) on the plane. Initially, your score is 0">0. To increase your score, you can ..
https://codeforces.com/contest/2063/problem/BCodeforces Round 1000(Div.2) - B. Subsequence Update문제 유형: 정렬, 그리디시간 제한: 1.5초메모리 제한: 256MB 문제You are given an integer sequence a1,a2,…,an">a1,a2,…,an, and a segment [l,r]">[l,r] (1≤l≤r≤n">1≤l≤r≤n).You must perform the following operation on the sequence exactly once.Choose any subsequence∗"> of the sequence a">a, and..
https://www.acmicpc.net/problem/10775BOJ - 공항문제 유형: 분리 집합, 그리디문제 난이도: Gold II시간 제한: 1초메모리 제한: 256MB 문제오늘은 신승원의 생일이다.박승원은 생일을 맞아 신승원에게 인천국제공항을 선물로 줬다.공항에는 G개의 게이트가 있으며 각각은 1에서 G까지의 번호를 가지고 있다.공항에는 P개의 비행기가 순서대로 도착할 예정이며, 당신은 i번째 비행기를 1번부터 gi (1 ≤ gi ≤ G) 번째 게이트중 하나에 영구적으로 도킹하려 한다. 비행기가 어느 게이트에도 도킹할 수 없다면 공항이 폐쇄되고, 이후 어떤 비행기도 도착할 수 없다.신승원은 가장 많은 비행기를 공항에 도킹시켜서 박승원을 행복하게 하고 싶어한다. 승원이는 비행기를 최대 몇 대 도..
https://codeforces.com/contest/2063/problem/ACodeforces Round 1000(Div.2) - A. Minimal Coprime문제 유형: 수학, 그리디시간 제한: 1초메모리 제한: 256MB 문제A segment of positive integers [l,r]">[l,r] is called coprime if l">l and r">r are coprime.A coprime segment [l,r]">[l,r] is called minimal coprime if it does not contain any coprime segment not equal to itself. To better understand this statement, you can refer to..
https://leetcode.com/problems/grid-game/description/leetcode - Grid Game문제 유형: 부분합, 구간합, 그리디문제 난이도: Medium 문제You are given a 0-indexed 2D array grid of size 2 x n, where grid[r][c] represents the number of points at position (r, c) on the matrix. Two robots are playing a game on this matrix.Both robots initially start at (0, 0) and want to reach (1, n-1). Each robot may only move to the right ((..
https://leetcode.com/problems/neighboring-bitwise-xor/description/leetcode - Neighboring Bitwise XOR문제 유형: 비트마스킹, 그리디문제 난이도: Medium 문제A 0-indexed array derived with length n is derived by computing the bitwise XOR (⊕) of adjacent values in a binary array original of length n.Specifically, for each index i in the range [0, n - 1]:If i = n - 1, then derived[i] = original[i] ⊕ original[0].Otherwise..
https://codeforces.com/contest/2055/problem/DCodeforces Round 996(Div.2) - D. Scarecrow문제 유형: 그리디, 구현, 수학시간 제한: 2초메모리 제한: 256MB 문제A crow is sitting at position 0">0 of the number line. There are n">n scarecrows positioned at integer coordinates a1,a2,…,an">a1,a2,…,an along the number line. These scarecrows have been enchanted, allowing them to move left and right at a speed of 1">1unit pe..
https://leetcode.com/problems/minimize-xor/description/leetcode - Minimize XOR문제 유형: 비트마스킹, 그리디문제 난이도: Medium 문제Given two positive integers num1 and num2, find the positive integer x such that:x has the same number of set bits as num2, andThe value x XOR num1 is minimal.Note that XOR is the bitwise XOR operation.Return the integer x. The test cases are generated such that x is uniquely determine..
https://codeforces.com/contest/2055/problem/BCodeforces Round 996(Div.2) - B. Crafting문제 유형: 수학, 그리디시간 제한: 1초메모리 제한: 256MB 문제There are n">n different types of magical materials, numbered from 1">1 to n">n. Initially, you have ai">ai units of material i">i for each i">i from 1">1 to n">n. You are allowed to perform the following operation:Select a material i">i (where 1≤i≤n">1≤i≤n)...