본문 바로가기
백준 1269 C++ https://www.acmicpc.net/problem/1269sort 이후 Index 옮기면서 풀면 간단한 문제다. #include using namespace std;int a, b; vector va, vb;int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> a >> b; int temp; for (int i = 0; i > temp; va.push_back(temp); } for (int i = 0; i > temp; vb.push_back(temp); } sort(va.begin(), va.end()); sort(vb.begin(), vb.end()); int Same = 0; int aIndex = 0, bI.. 2025. 2. 10.
백준 1269 C++ https://www.acmicpc.net/problem/1269sort 이후 Index 옮기면서 풀면 간단한 문제다. #include using namespace std;int a, b; vector va, vb;int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> a >> b; int temp; for (int i = 0; i > temp; va.push_back(temp); } for (int i = 0; i > temp; vb.push_back(temp); } sort(va.begin(), va.end()); sort(vb.begin(), vb.end()); int Same = 0; int aIndex = 0, bI.. 2025. 2. 9.
백준 7795 C++ https://www.acmicpc.net/problem/7795간단하게 sort해서 풀 수 있는 문제였습니다.#include using namespace std;//A는 B를 먹는다. A는 자기보다 크기가 작은 B만 먹을 수 있다.//이런 쌍이 몇가기 있는가?int testCase, a, b;vector va, vb;int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> testCase; for (int t = 0; t > a >> b; //a집합 b집합 입력 int temp, result = 0; va.clear(); vb.clear(); for (int i = 0; i > temp; va.push_back(tem.. 2025. 2. 9.
백준 6236 C++ https://www.acmicpc.net/problem/6236 이 문제도 바이너리 서치로 풀 수 있는 문제였다.#include using namespace std;int n, m; //m번만 돈을뺀다.int result = 100000 * 10000 + 100;vector v;bool check(int num){ int a = 0; int takeMoney = 1; for (int i : v) { a += i; if (i > num) return false; //이미 하루가 num보다 크다. -> 금액이 맞지 않다. if (a > num) { //총합 한 값이 하루의 금액보다 크다. a = i; takeMoney += 1; } } return takeMoney > n >> m; .. 2025. 2. 9.
백준 2792 C++ https://www.acmicpc.net/problem/2792간단하게 바이너리 서치로 풀 수 있는 문제였습니다. #include using namespace std;int n, m;int result = 987654321;vector v;bool check(int num){ int a = 0; for (int i : v) { a += i / num; //num개로 나눴을 때 받는 학생의 수 if (i % num != 0) a += 1; } return a }int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; //n명의 학생, m개의 색상 수 //각 색상별 개수 push int temp; for .. 2025. 2. 7.
백준 17822 C++ https://www.acmicpc.net/problem/17822이 문제도 첫 인상이 괴랄하게 생겼다.무슨 (i,1) ~~ 인접하다. 복잡하게 생겼다.이 글을 보고 생각하는 것 보다 밑에 예제를 보는 것이 훨씬 낫다.예제를 보면 n, m, t 등등이 무엇을 의미하는지 어떻게 작동하는지 쉽게 알 수 있다.그래서 문제에서 요구하는 점을 하나씩 구현하면 해결은 쉽게 할 수 있다. array를 회전하는 것은 힘들 것으로 판단되서 deque로 front, back을 사용했다. #include using namespace std;int n, m, turnCount; //n = 원판의 개수, m = 각 원판에 적힌 수의 개수, t = 회전횟수vector> circles(55);int dy[] = { -1,.. 2025. 1. 30.