백준/GOLD

    [백준 9084번][C++] 동전

    ### 분류 다이나믹 프로그래밍(dp), 배낭 문제(knapsack) #include #include using namespace std; int main() { int test; cin >> test; //indexdml 금액을 달성하는 방법의 개수 vector total_cnt(10000, 0); while(test--){ //코인 종류 개수 입력 int coin_cnt; cin >> coin_cnt; //코인 종류 입력 vector coin_list; for (int i = 0; i > input; coin_list.push_back(input); } //방법을 찾아야하는 목표 금액 int target_money; cin >> target..

    [백준 1715번][C++] 카드 정렬하기

    #include #include using namespace std; int main() { //테스트 케이스 입력받기 int n; cin >> n; //총 계산횟수 구하는 변수 int total_cnt = 0; //우선순위 큐를 오름차순으로 저장 priority_queue pq; //카드 더미수 입력받고 우선순위 큐에 저장 while (n--) { int input; cin >> input; pq.push(input); } //큐 안에 저장된 원소가 1개가 될 때까지 //가장 적은 수를 가진 더미 2개를 뽑아 더해서 다시 더미에 넣고 //합 한 수는 총 계산 횟수에 업데이트 해줌 while (pq.size() != 1) { int input1, input2; input1 = pq.top(); pq.po..

    [백준 7662번][C++] 이중 우선순위 큐

    #include #include #include using namespace std; int main() { int test; cin >> test; while (test--) { //각각 최대힙과 최소힙 priority_queue min_heap; priority_queue max_heap; //삭제된 인덱스 저장 map del_idx; // 입력 데이터의 수 int input; cin >> input; for (int i = 0; i > c >> check_num; //삽입연산일 때 if (c == 'I') { //최대힙 최소힙 둘다 값저장 max_heap.push(check_num); min_h..

    [백준 10026번][C++] 적록색약

    적록색약의 구역을 구할 때는 R이나 G 한 쪽을 정해 바꿔버리고 다시 탐색했습니다 #include #include #include #include using namespace std; //좌표 클래스 class Point { public: int x; int y; Point(int x, int y) { this->x = x; this->y = y; } ~Point(){} }; //monitor에 저장될 Data 클래스 class Data { public: char color; int isVisited = 0; Data(char color) { this->color = color; } ~Data(){} }; //크기 int n; //Data클래스 저장할 벡터 vector monitor(105, vector..

    [백준 7565번][C++] 토마토

    기본적인 아이디어 토마토 판을 의미하는 2차원 벡터 생성후 숫자들 삽입 (이때 벡터에서의 잘못된 접근을 피하기 위해 첫 번째 줄인 인덱스 0을 비워둡니다) 삽입할 때 1의 숫자가 들어오는 죄표을 먼저 큐에 저장하고 첫 번째 단계라고 정의합니다 삽입이 끝나고 첫번째 단계의 큐 원소부터 주변의 0들의 값을 자신+1의 값(날짜를 의미)으로 업데이트해주며 큐에 저장해줍니다 첫번째 단계 큐의 원소들의 작업이 끝나면 두번째 단계 큐의 원소부터 다시 작업을 합니다 #include #include #include using namespace std; //주변 좌표를 탐색할 수 있도록 인덱스에 더할 값 배열 저장 int xPoint[4] = {-1, 0, 1, 0}; int yPoint[4] = {0, -1, 0, 1}..