본문 바로가기

Algorithm/프로그래머스139

[프로그래머스]2019 KAKAO BLIND RECRUITMENT : 무지의 먹방 라이브 (level 4) (c++) programmers.co.kr/learn/courses/30/lessons/42891 코딩테스트 연습 - 무지의 먹방 라이브 programmers.co.kr 정렬 #include #include #include #include using namespace std; using ll = long long; struct food { int idx; ll time; }; bool comp_by_time(food &A, food &B) { return A.time < B.time; } bool comp_by_idx(food& A, food& B) { return A.idx < B.idx; } int solution(vector food_times, long long k) { // {인덱스, 시간} 벡터 생성 v.. 2020. 9. 6.
[프로그래머스]2019 KAKAO BLIND RECRUITMENT : 길 찾기 게임 (level 3) (c++) https://programmers.co.kr/learn/courses/30/lessons/42892 코딩테스트 연습 - 길 찾기 게임 [[5,3],[11,5],[13,3],[3,5],[6,1],[1,3],[8,6],[7,2],[2,2]] [[7,4,6,9,1,8,5,2,3],[9,6,5,8,1,4,3,2,7]] programmers.co.kr 트리 & 그래프 만들기 + 전위 순회, 후위 순회 #include #include #include #include using namespace std; const int X_MAX = 100000; struct node { int no; int x, y; int limit_L, limit_R; }; // y내림차순, x오름차순 비교함수 struct compare .. 2020. 7. 11.
[프로그래머스]Summer/Winter Coding(~2018) : 배달 (level 3) (c++) https://programmers.co.kr/learn/courses/30/lessons/12978 코딩테스트 연습 - 배달 5 [[1,2,1],[2,3,3],[5,2,2],[1,4,2],[5,3,1],[5,4,2]] 3 4 6 [[1,2,1],[1,3,2],[2,3,2],[3,4,3],[3,5,2],[3,5,3],[5,6,1]] 4 4 programmers.co.kr bfs #include #include #include using namespace std; const int INF = 987654321; // 1번 마을에서 K의 시간내에 배달할 수 있는 마을 개수 구하기 int bfs(vector &v_adj, int N, int K) { // 1번 마을에서 N번째 마을까지의 최소 시간을 저장 ve.. 2020. 7. 10.
[프로그래머스]2019 카카오 개발자 겨울 인턴십 : 징검다리 건너기 (level 3) (c++) https://programmers.co.kr/learn/courses/30/lessons/64062 코딩테스트 연습 - 징검다리 건너기 [2, 4, 5, 3, 2, 1, 4, 2, 5, 1] 3 3 programmers.co.kr 이분탐색 #include #include #include using namespace std; const int MAX = 200000000; bool check(vector &stones, int k, int passed) { // 왼쪽 땅부터 시작 int last_idx = -1; for (int i = 0; i = 0) { // 마지막 디딤돌간의 간격이 k.. 2020. 7. 10.