목록그리디 (88)
넘치게 채우기
https://leetcode.com/problems/divide-players-into-teams-of-equal-skill/description/?envType=daily-question&envId=2024-10-04leetcode - Divide Players Into Teams of Equal Skill문제 유형 : 정렬, 그리디, 투 포인터문제 난이도 : Medium 문제You are given a positive integer array skill of even length n where skill[i] denotes the skill of the ith player. Divide the players into n / 2 teams of size 2 such that the total skil..
https://codeforces.com/contest/2013/problem/DCodeforces Round 973(Div. 2) - D. Minimize the Difference문제 유형 : 스택, 부분합, 그리디제한 시간: 2초제한 메모리: 256MB 문제Zhan, tired after the contest, gave the only task that he did not solve during the contest to his friend, Sungat. However, he could not solve it either, so we ask you to try to solve this problem.You are given an array a1,a2,…,an">𝑎1,𝑎2,…,𝑎?..
https://codeforces.com/contest/2013/problem/BCodeforces Round 973(Div. 2) - B. Battle for Survive문제 유형 : 그리디제한 시간: 1초제한 메모리: 256MB 문제Eralim, being the mafia boss, manages a group of n">𝑛n fighters. Fighter i">𝑖i has a rating of ai">𝑎𝑖ai.Eralim arranges a tournament of n−1">𝑛−1n−1 battles, in each of which two not yet eliminated fighters i">𝑖i and j">𝑗j (1≤i<j≤n">1≤..
https://www.acmicpc.net/problem/1080BOJ - 1080: 행렬문제 유형 : 행렬, 그리디, 비트마스크문제 난이도 : Silver I 문제0과 1로만 이루어진 행렬 A와 행렬 B가 있다. 이때, 행렬 A를 행렬 B로 바꾸는데 필요한 연산의 횟수의 최솟값을 구하는 프로그램을 작성하시오.행렬을 변환하는 연산은 어떤 3×3크기의 부분 행렬에 있는 모든 원소를 뒤집는 것이다. (0 → 1, 1 → 0) 입력첫째 줄에 행렬의 크기 N M이 주어진다. N과 M은 50보다 작거나 같은 자연수이다. 둘째 줄부터 N개의 줄에는 행렬 A가 주어지고, 그 다음줄부터 N개의 줄에는 행렬 B가 주어진다. 출력첫째 줄에 문제의 정답을 출력한다. 만약 A를 B로 바꿀 수 없다면 -1을 출력한다. 풀이이 ..
https://www.acmicpc.net/problem/21558BOJ - 전쟁 준비하기문제 유형 : 구현, 수학, 그리디문제 난이도 : Silver I 문제이번에 폴리매스 왕국은 이웃 나라인 사이언스보드를 정복하기 위해 전쟁을 치르려고 합니다. 당신은 전쟁에서 사용할 방진을 짜 달라는 부탁을 받아 방진을 연구하고 있습니다.전쟁 지역의 지형상 가장 효율적인 방진은 직사각형 구조일 것으로 보입니다.즉 X행Y열의 직사각형을 정확히 XY명의 병사가 채우고 있는 형태를 말합니다. 병사의 수가 정확히 떨어지지 않아 몇 명이 남거나 부족한 경우에는 이러한 방진을 짤 수 없습니다.폴리매스 문명은 예전에도 강력한 군사력으로 주변의 약소국을 다수 복속시켰으므로, 군대에도 서로 다른N개의 민족이 섞여 있습니다. 특히, ..
https://leetcode.com/problems/find-the-student-that-will-replace-the-chalk/description/?envType=daily-question&envId=2024-09-02leetcode - Find the Student that Will Replace the Chalk문제 유형 : 그리디, 수학문제 난이도 : Medium 문제There are n students in a class numbered from 0 to n - 1. The teacher will give each student a problem starting with the student number 0, then the student number 1, and so on until t..
https://leetcode.com/problems/lemonade-change/description/?envType=daily-question&envId=2024-08-15leetcode - Lemonade Change문제 유형 : 그리디문제 난이도 : Easy 문제At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you and order one at a time (in the order specified by bills). Each customer will only buy one lemonade and pay with either a $5, $10, or $20 bill. You must..
https://leetcode.com/problems/minimum-number-of-days-to-disconnect-island/description/leetcode - Minimum Number of Days to Disconnect Island문제 유형 : bfs / dfs, 그리디문제 난이도 : Hard 문제You are given an m x n binary grid grid where 1 represents land and 0 represents water. An island is a maximal 4-directionally (horizontal or vertical) connected group of 1's.The grid is said to be connected if we have e..
https://leetcode.com/problems/find-valid-matrix-given-row-and-column-sums/description/leetcode - Find Valid Matrix Given Row and Column Sums문제 유형 : 그리디, 행렬문제 난이도 : Medium 문제You are given two arrays rowSum and colSum of non-negative integers where rowSum[i] is the sum of the elements in the ith row and colSum[j] is the sum of the elements of the jth column of a 2D matrix. In other words, you do n..
https://leetcode.com/problems/maximum-score-from-removing-substrings/leetcode - Maximum Score From Removing Substrings문제 유형 : 그리디, 스택, 슬라이딩 윈도우 문제 난이도 : Medium 문제You are given a string s and two integers x and y. You can perform two types of operations any number of times. Remove substring "ab" and gain x points. For example, when removing "ab" from "cabxbae" it becomes "cxbae". Remove substring..