본문 바로가기

코딩 테스트

(76)
백준 10989 계수 정렬을 사용하였는데도 메모리 부족이 나왔다. 입력 시 vector 의 사이즈를 다시 설정해주면서 count 배열로 만들고 그대로 출력 시켜서 메모리 부족을 해결했다. 배열 하나만 사용하였다. #include #include using namespace std; int main(void) { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int num = 0; int max = 0; cin >> num; vector nums; for (int i = 0; i > push; if (push < nums.size()) { nums[push-1]++; } else { nums.resize..
백준 1874 #include #include #include #include #include using namespace std; int main(void) { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); stack stacks; vector vectors; int pushNum = 1; int input = 0; cin >> input; for (int i = 0; i > num; while (1) { if (!stacks.empty()) { if (stacks.top() num) { cout
백준 11650 2차원 좌표 평면의 (x,y)의 좌표 정렬 문제. x,y 를 가지는 PINT2 구조체를 만들어 동적할당으로 배열 크기를 정해주고 sort 알고리즘에 Compare 함수를 만들어서 풀었다. #include #include #include #include using namespace std; struct PINT2 { int x; int y; }; bool Compare(PINT2 a, PINT2 b); int main(void) { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int pointNum = 0; cin >> pointNum; PINT2* points; points = new PINT2[pointNum]; for (int i = 0;..
백준 1120 #include #include using namespace std; int main(void) { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string a, b; cin >> a >> b; int num2 = 50; int num3 = a.size(); // hello int num4 = b.size(); // asdqwe for (int i = 0; i = num) { num2 = num; } if (num3 > num..