728x90
목록정렬 (2)
컴공댕이 공부일지
[ C++/cpp ] 백준 (10814 나이순 정렬) ⭐sort_stable
백준 10814번 나이순 정렬 (실버 5) https://www.acmicpc.net/problem/10814 (정답 코드) #include #include #include using namespace std; typedef pair p; bool cmp(const p &a, const p &b) { // 나이순 정렬 if(a.first!=b.first) { return a.first < b.first; } // 나이가 같으면 변화없이 그대로 ! else { return false; // 원래 순서 유지 ! } } void sortUser(vector& user) { // 입력 순서를 보존하는 안정적인 정렬을 보장하는 sort_stable stable_sort(user.begin(), user.end()..
문제 풀이/코딩 문제 풀이 모음
2024. 3. 2. 01:16

✅ 버블 정렬 / Bubble sort O(n^2) ☑️ 인접한 두 원소를 비교해 swap ! (오름차순 기준) 가장 큰 원소부터 오른쪽 끝에 배치 버블 정렬 C++ 코드 void bubbleSort(vector& arr) { for(int i=0; i 해결된 조각들을 다시 합침 합병 정렬 예시 코드 #include #include using namespace std; vector sorted; void merge(vector& arr, int left, int mid, int right) { int pl=left, pr=mid+1, idx=left; while(pl
기록/알고리즘 스터디 알튜비튜 5기✨
2023. 8. 23. 09:54
728x90