This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//유의할 점 | |
//문제의 제한 시간과 주어지는 테스트 케이스의 수를 잘 확인해보자 | |
//시간복잡도를 계산해보고 문제를 풀 수 있도록 한다. | |
#include <iostream> //io | |
using namespace std; | |
int N = 0; //초기 쿠폰 수 | |
int K = 0; //치킨을 교환하기 위한 쿠폰의 수 | |
int order_sum = 0; //테스트 케이스 별 총 주문 수 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//주어진 두 수열( A, B)에 대해 | |
//B에 속한 원소가 A배열에 존재하는지 확인하여야하므로 | |
// 단순 비교로는 O( A * B )가 될 것이다. | |
// 주어진 입력값의 범위는 A = 1 ~ 100000, B = 1 ~ 100000 으로 2초 이내에 계산이 불가능 | |
// 값의 범위는 정해져있지만 들어오는 값이 오름차순이 아니기에 | |
// 오름차순 정렬 후 이분탐색을 이용하여 처리 | |
// 정렬은 이전에 활용한 합병정렬을 사용~ | |
// 유의사항, 결과값 출력에 대해 cout >> endl을 사용할 시 시간촤과가 나왔고 | |
//이에 대해 검색한 결과 endl을 '\n'로 변경하여 문제를 해결하였다. | |
//endl을 출력 버퍼를 비우는 작업을 병행하기 때문에 보다 느린 관계로 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//길목마다 벽이 세워져있을 수 있는 NxM 지도에서 | |
//최단 경로로 목적지에 도달했을때의 이동횟수를 구하는 문제 | |
//벽을 한번 부수고 이동할 수 있다는 가정이 있기에 | |
//NxM 행렬에 대해 벽을 한번 부순 모든 경우를 찾아 | |
//벽을 부수지 않은 경우와 벽을 부순 모든 경우 중 | |
//최단 경로의 값을 리턴하면 되는 문제 | |
//시간 복잡도를 계산해보고 문제에 접근하도록 하자 | |
//brute force 형태로도 답을 구할 순 있지만... 결과는 ㅎㅎ... | |
#include <iostream> //io | |
#include <queue> //queue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <queue> | |
#include <vector> | |
#include <tuple> | |
using namespace std; | |
#define STAR 1 | |
//테스트 입력값 | |
int N = 0, M = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//유의사항 | |
//해당 문제의 주어지는 입력 크기를 잘 확인하자 | |
//무턱대고 정렬한다면 시간초과가 뜰 것이다 | |
//아래 코드는 합병정렬을 이용하여 답을 구하였다 | |
#include <iostream> //io | |
using namespace std; | |
//입력받을 배열 A(N) B(M)의 크기 선언 및 초기화 | |
int N = 0, M = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//유의사항 | |
//브론즈 문제라지만 의외로 많은 생각을 요구하는 문제이다. | |
//수식으로 풀면 더 간단할 수 있지만 | |
//이분탐색으로 꼭 풀어보길 추천한다. | |
//이분탐색에 대한 응용법이나 보다 깊이 이해할 수 있게 해주는 문제이다 | |
#include <iostream> // io | |
using namespace std; | |
//달팽이가 오르고(A) 내리고(B) 도달해야하는(V)값의 변수 선언 | |
unsigned long A, B, V; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> //io | |
#include <queue> // queue | |
using namespace std; | |
#define DFS 0 | |
#define BFS 1 | |
//노드의 개수와 간선의 개수를 입력받기 위한 변수 선언 및 초기화 | |
int N = 0, M = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> //io | |
#include <string> //string | |
#include <vector> //vector | |
#include <queue> //queue | |
using namespace std; | |
//단지 정보가 입력될 인접행렬 선언 | |
int map[25][25]; | |
//중복 방문을 방지하기 위한 행렬 선언 | |
int check[25][25]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> // io | |
#include <queue> // queue | |
#include <tuple> // tuple | |
#include <cstring> // memset | |
using namespace std; | |
int T = 0; //테스트 케이스 횟수를 입력받을 변수 | |
int N = 0; //체스판 한 변의 길이 | |
//int cur_loc[2] = {0,0}; // 현재 위치 | |
//int dest_loc[2] = { 0,0 }; //목적지 위치 | |
int cur_x = 0, cur_y = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> // io | |
#include <queue> // queue | |
#include <cstring> // memset | |
using namespace std; | |
//문제의 입력값에 대한 변수 선언 및 초기화 | |
int N = 0, M = 0, V = 0; | |
//입력받은 간선의 정보를 저장할 인접행렬 선언 | |
//인접행렬의 크기는 문제에서 주어진 최대 제한값 1000x1000으로 선언하였지만 |
OlderNewer