#프로그래머스 #2단계 #c++ 43

프로그래머스 - 마법의 엘리베이터 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/148653 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr #include using namespace std;int solution(int storey) { int answer = 0; while(storey>0) { int im = storey%10; storey/=10; int next = storey%10; if(im>5||(im==5 && next >= 5)) { ..

프로그래머스 - 디펜스 게임 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/142085 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr #include #include #include using namespace std;int solution(int n, int k, vector enemy) { int answer = 0; priority_queue,greater> pq; int total_damage=0; for(int i=0;ik) { total_damage+=pq.t..

프로그래머스 - 점 찍기 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/140107 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr #include #include #include using namespace std;long long solution(int k, int d) { long long answer = 0; for(int x=0;x 원점부터 k 간격으로 x와 y를 점 찍을 수 있는데, 원점으로의 거리가 d를 넘으면 안된다. 이 때, 몇개의 점을 찍을 수 있는가가 문제이다.  x를 0부터 시작해서 최대 ..

프로그래머스 - 시소 짝꿍 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/152996 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr #include #include #include using namespace std;long long solution(vector weights) { long long answer = 0; unordered_mapum; for (int i = 0; i item : um) { int key = item.first; if (um[key] >= 2) ..

프로그래머스 - 귤 고르기 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/138476 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr #include #include #include #include using namespace std;int solution(int k, vector tangerine) { int answer = 1; unordered_map um; for(int it : tangerine) um[it]++; vector> v; for(auto& it : um) ..

프로그래머스 - 광물캐기 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/172927 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr #include #include using namespace std;int answer=1500;void recur(int t,int d,int i,int s,int size,vector& minerals){ if(size==minerals.size()||(d==0&&i==0&&s==0)) { if(answer>t)answer=t; return; } i..

프로그래머스 - 배달 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/12978 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr #include #include using namespace std;int solution(int N, vector > road, int K) { int answer = 0; vector> dist(N+1,vector(N+1,1e9)); for(auto& item :road) { if(dist[item[0]][item[1]]!=1e9) { ..

프로그래머스 - 카카오프렌즈 컬러링 북 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/1829 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr #include using namespace std;int dy[4]={0,1,0,-1};int dx[4]={-1,0,1,0};bool CheckPos(int x,int y,int m,int n){ if(x>=0 && x=0 && y>& board, vector>& ch,int x,int y,int type,int& cnt,int m,int n){ for(int i=0;i so..

프로그래머스 - 가장 큰 수 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/42746 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr #include #include #include using namespace std;bool compare(int a, int b){ string sa=to_string(a); string sb = to_string(b); return sa+sb > sb+sa;}string solution(vector numbers) { string answer = ""; stable_so..

프로그래머스 - 괄호 변환 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/60058 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr #include #include using namespace std;string solution(string p) { string u = ""; if(p=="")return ""; // 분리 int cnt=0; bool b = true; string v=""; for(int i=0;i이 문제는 재귀함수를 이용해 주어진 알고리즘대로 돌아가게끔 코드를 만들어 리턴하는..