[C++] 백준 1939 중량제한
·
Algorithm/Baekjoon
#include #include #include #include using namespace std; const int MaxNum = 100001; int n, m, start, finish; bool visited[MaxNum]; vector nodes[MaxNum]; bool BFS(int cost); int main() { ios_base::sync_with_stdio(0); cin.tie(0); int lowCost, highCost, maxCost; cin >> n >> m; for (int i = 0; i > temp1 >> temp2 >> temp3; nodes[temp1].push_back({ temp2, temp..
[C++] 백준 11650 좌표 정렬하기
·
Algorithm/Baekjoon
#include #include #include using namespace std; int main() { ios::sync_with_stdio(false); int n = 0; cin >> n; vector point(n);//빈값 생성 for (int i = 0; i > point[i].first >> point[i].second;//바로 값을 변수에 받아옴 sort(point.begin(), point.end());//왼쪽이 높은 순으로 정렬후 오른쪽 높은순으로 정렬됨 for (int i = 0; i < n; i++) cout
[C++] 백준 10989 수 정렬하기 - 계수정렬(Counting Sort)
·
Algorithm/Baekjoon
#include using namespace std; int main() { ios::sync_with_stdio(false); int countNum[10001]{ 0 }; int n, i; cin >> n; for (i = 0; i > temp; countNum[temp]++; } for (i = 1; i < 10001; i++) { for (int j = 0; j < countNum[i]; j++) cout
[C++] 백준 2751 수 정렬하기 - 재귀, 병합정렬
·
Algorithm/Baekjoon
#include #include using namespace std; vector num; vector tempNum; void MergeDivied(vector *list, int left, int right); void MergeSort(vector &list, int left, int mid, int right); int main() { int n = 0; cin >> n; for (int i = 0; i > temp; num.push_back(temp); tempNum.push_back(0); } MergeDivied(&num, 0, n - 1); for (int i = 0; i < n; i++) { cout
[C++] 백준 11729 하노이 탑 - 재귀
·
Algorithm/Baekjoon
#pragma once #include using namespace std; void Hanoi(int n, int from, int to, int other); int main() { int i = 0; cin >> i;//입력값 //몇 번 이동하는지 { int hanoiNum = 2; for (int y = 0; y 3 ) - Hanoi(n - 1, o..
[C++] 백준 10872 팩토리얼 - 재귀
·
Algorithm/Baekjoon
#include using namespace std; void factorial(int k); int x = 1; int y = 1; int main() { cin >> x;//정수를 입력 받는다. factorial(1); cout