본문 바로가기

반응형

Algorithm_BOJ(백준)/이진탐색

(14)
[백준 2143 c++ V] 두 배열의 합 - 풀이 링크: https://github.com/xhaktmchl/Algorithm_study/blob/main/BOJ/%EC%9D%B4%EC%A7%84%ED%83%90%EC%83%89/%5B%EB%B0%B1%EC%A4%80%202143%20c%2B%2B%20V%5D%20%EB%91%90%20%EB%B0%B0%EC%97%B4%EC%9D%98%20%ED%95%A9.cpp GitHub - xhaktmchl/Algorithm_study: 알고리즘 이론 및 문제풀이 알고리즘 이론 및 문제풀이. Contribute to xhaktmchl/Algorithm_study development by creating an account on GitHub. github.com #include #include #includ..
[백준 2110 c++ V] 공유기 설치 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 #define _CRT_SECURE_NO_WARNINGS #include #include #include #include // memset 헤더 using namespace std; // [백준 2110 c++ V] 공유기 설치 // 문제: // 접근1: 최댓값 -> 완탐/그리디/dp/이진탐색 -> 완전탐색 -> 10억*20만 이어서 시간초과 // 접근2: 최댓값 -..
[백준 2805 c++ V] 나무 자르기 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 #define _CRT_SECURE_NO_WARNINGS #include #include #include #include // memset 헤더 #include using namespace std; // [백준 2805 c++ V] 나무 자르기 // 문제: // 접근1: 최댓값 -> 완탐/그리디/dp/이진탐색 -> 완전탐색 -> 20억 이어서 시간초과 // 접근2: 최댓값 -> 완탐/그리디/dp/이진탐색 -> 이진탐색 ..
[백준 1654 c++ V] 랜선 자르기 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 #define _CRT_SECURE_NO_WARNINGS #include #include #include #include // memset 헤더 #include using namespace std; // [백준 1654 c++ V] 랜선 자르기 // 문제: 숫자 있는지 출력 // 접근1: 완전탐색 -> 50만*2^31이어서 시간초과 // 접근2: 이진탐색 직접구현-> 랜선의 길이 low=1, high=최..
[백준 10816 c++ V] 숫자 카드 2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 #define _CRT_SECURE_NO_WARNINGS #include #include #include #include // memset 헤더 #include using namespace std; // [백준 10816 c++ V] 숫자 카드 2 // 문제: 숫자 있는지 출력 // 접근1: 완전탐색 -> 50만*50만 이어서 시간초과 // 접근2: 벡터 정렬 후 lower_bound ,upper_bound 함수의 차가 그 원소의 갯수 // 시간복잡도: // 풀이: // 배열 입력 ..
[백준 1920 c++ V] 수 찾기 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 #define _CRT_SECURE_NO_WARNINGS #include #include #include #include // memset 헤더 #include using namespace std; // [백준 1920 c++ V] 수 찾기 // 문제: 숫자 있는지 출력 // 접근1: 벡터에서 find 로 숫자 찾기 -> 맞음 근데 이진탐색보다 느림 // 접근2: binary_search 함수로 원소 찾기 -> 일반 find보다 빠름 // 시간복잡도: O(n+mlog2(n)) ..

반응형