그럴듯한 개발 블로그
[프로그래머스 고득점kit] 완전탐색_전력망을 둘로 나누기 c++ (set)

https://school.programmers.co.kr/learn/courses/30/lessons/86971?language=cpp 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 연결된 전력망을 하나씩 끊었을 때 모든 상황을 다 찾아서 비교한다. #include #include #include #include using namespace std; int N; int getDiffWithCutWire(vector wires, int cutIdx) { // ref로 받지 않았다 복사한 wires임 unordered_set groupA; groupA.in..

[프로그래머스 고득점kit] 그리디_체육복(c++)

https://school.programmers.co.kr/learn/courses/30/lessons/42862?language=cpp 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 맨 처음에 푼 방법 #include // 처음 풀이 #include #include using namespace std; int solution(int n, vector lost, vector reserve) { int answer = n - lost.size(); sort(lost.begin(), lost.end()); sort(reserve.begin(), reserve..

[프로그래머스 고득점kit] 완전탐색_피로도(c++)(순열 풀이)

https://school.programmers.co.kr/learn/courses/30/lessons/87946?language=cpp 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr dfs가 바로 떠올랐다. 하지만 완전탐색으로 분류된 문제인 만큼 완전탐색으로 풀고 싶었다. 순열을 순회할 수 있는 next_permutation함수를 사용하여 해결했다. #include #include #include #include using namespace std; int get_explore_cnt(vector v, vector dungeons, int k) { in..

[프로그래머스 고득점kit] 완전탐색_카펫(c++)

https://school.programmers.co.kr/learn/courses/30/lessons/42842?language=cpp 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include using namespace std; int get_brown(int width, int height) { return (2 * (width + 2) + 2 * height); } vector solution(int brown, int yellow) { vector answer; for (int i = 1; i

[프로그래머스 고득점kit] 정렬_H_index(c++)

#include #include #include using namespace std; int solution(vector citations) { int n = citations.size(), i; sort(citations.begin(), citations.end(), greater()); for (i = 1; i citations[i - 1]) return (i - 1); return (i - 1); } 진짜 역대급으로 해석이 안 되는 문제였다. 출제자님 미워요..... 문제 이해만 하면 매우 쉬운 문제였다.

[프로그래머스 고득점kit] 정렬_가장 큰 수(c++)

https://school.programmers.co.kr/learn/courses/30/lessons/42746?language=cpp 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 보자마자 제일 앞 자릿수만 비교하면 되겠다 싶어 vector 선언하고 정렬했는데 다음 자릿수를 걸러주지 못했다. ex) 303, 340 #include #include #include #include using namespace std; int get_first_digit(int n) { int digit = -1, tmp = n; while (tmp > 0) { tmp /..