[BOJ] 1874번 스택 수열 (C++)
https://www.acmicpc.net/problem/1874 1874번: 스택 수열 1부터 n까지에 수에 대해 차례로 [push, push, push, push, pop, pop, push, push, pop, push, push, pop, pop, pop, pop, pop] 연산을 수행하면 수열 [4, 3, 6, 8, 7, 5, 2, 1]을 얻을 수 있다. www.acmicpc.net #include #include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int arr[100000]; for(int i = 0; i > arr..
[BOJ] 13904번 과제 (C++)
https://www.acmicpc.net/problem/13904 13904번: 과제 예제에서 다섯 번째, 네 번째, 두 번째, 첫 번째, 일곱 번째 과제 순으로 수행하고, 세 번째, 여섯 번째 과제를 포기하면 185점을 얻을 수 있다. www.acmicpc.net #include #include #include using namespace std; int main() { int n; cin >> n; vector v; int arr[1001] = {0, }; for(int i = 0; i > d >> w; v.push_back({w, d}); } sort(v.begin(), v.end(), greater()); int sum = 0; for(int i =..
[BOJ] 2665번 미로 만들기 (C++)
https://www.acmicpc.net/problem/2665 2665번: 미로만들기 첫 줄에는 한 줄에 들어가는 방의 수 n(1 ≤ n ≤ 50)이 주어지고, 다음 n개의 줄의 각 줄마다 0과 1이 이루어진 길이가 n인 수열이 주어진다. 0은 검은 방, 1은 흰 방을 나타낸다. www.acmicpc.net #include #include #include using namespace std; int n; int arr[50][50]; int visited[50][50]; int dx[4] = {-1, 0, 0, 1}; int dy[4] = {0, -1, 1, 0}; void bfs(){ queue q; q.push({0, {0, 0}}); while(!q.empty()){ int cnt = q.fro..
[BOJ] 7569번 토마토 (C++)
https://www.acmicpc.net/problem/7569 7569번: 토마토 첫 줄에는 상자의 크기를 나타내는 두 정수 M,N과 쌓아올려지는 상자의 수를 나타내는 H가 주어진다. M은 상자의 가로 칸의 수, N은 상자의 세로 칸의 수를 나타낸다. 단, 2 ≤ M ≤ 100, 2 ≤ N ≤ 100, www.acmicpc.net #include #include #include using namespace std; int m, n, h; int arr[100][100][100]; int dist[100][100][100]; queue q; int dx[6] = { 1, -1, 0, 0, 0, 0 }; int dy[6] = { 0, 0, -1, 1, 0, 0 }; int dz[6] = { 0, 0, 0..