본문 바로가기

백준(C++)/정렬9

[BOJ/C++]10989번_수정렬하기3 https://www.acmicpc.net/problem/10989 ##문제 풀기 전 내가 알고 있었어야 할 개념:1_ 메모리 초과 문제 :=> 1차 시도의 메모리 초과 이유 : 헤더파일 + qsort 연산에서 공간 메모리 초과 사용2_ Time Limit => 시간 복잡도 : 2_1) 보통의 과정 (버블정렬, 퀵정렬...) 에서 O(n^2)의 이상의 시간 복잡도가 나온다. 2_ 2) 에서 사용되는 cin, cout, endl 등등의 표준 stream 동기화 시간=> (2_2)의 해결방법 : [코드]에 있는 init()함수 선언, 호출 123456void init() {     ios::sync_with_stdio(false);    cin.tie(0);    cout.tie(0);}cs3_ 문제 원리.. 2024. 7. 10.
[BOJ/C++]25305번_커트라인 https://www.acmicpc.net/problem/25305 ##문제 풀기 전 내가 알고 있었어야 할 개념: 없음123456789101112131415161718192021222324252627282930313233#include iostream>#include algorithm> using namespace std; int compare(const void* a, const void* b) {    return (*(int*)b - *(int*)a);} int main() {     ios::sync_with_stdio(false);    cin.tie(0);    cout.tie(0);     int N,K;    int* scores;    cin >> N >> K;     scores = .. 2024. 7. 10.
[BOJ/C++]2587번_대표값2 https://www.acmicpc.net/problem/2587##문제를 풀기 위해 알아야 할 개념 :이 문제는 입력 개수가 5개로 한정되어 매우 쉬운편중앙값 ≠ 점수의 등수  => 따라서, 등수 매기는 문제를 찾아보아서 풀어보기 (BOJ_1205번)[https://www.acmicpc.net/problem/1205]  123456789101112131415161718192021222324252627282930313233#include iostream>#include algorithm>#define SIZE 5 using namespace std; int compare(const void* a, const void* b) {    return (*(int*)a - *(int*)b);} int main(.. 2024. 7. 8.
[BOJ/C++]2750번_수정렬하기 https://www.acmicpc.net/problem/2750##문제 풀기 전 내가 알고 있었어야 할 개념:※ C++에서 QuickSort 헤더 라이브러리 사용 방법  => 자세한 내용은 https://kojammin.tistory.com/24 에 적어 놓았다. 123456789101112131415161718192021222324252627282930313233#include iostream>#include algorithm>//퀵 소트 사용을 위한 헤더#define SIZE 1000//문제 조건의 N의 크기 (1000) using namespace std; //작은 순으로 정렬 compareint compare(const void* a, const void* b) {    return (*(int.. 2024. 7. 7.