목록C++ (24)
Try
출처 https://programmers.co.kr/learn/courses/30/lessons/1845 알고리즘 연습 - 폰켓몬 | 프로그래머스 실행 결과가 여기에 표시됩니다. programmers.co.kr 소스 #include #include using namespace std; int solution(vector nums) { int cnt = 1; int pick = nums.size() / 2; int answer = 0; sort(nums.begin(), nums.end()); for(int i= 0; i pick){ answer = pick; } else{ answer..
출처https://programmers.co.kr/learn/courses/30/lessons/49993?language=cpp# 소스123456789101112131415161718192021222324252627282930313233343536#include #include using namespace std; int solution(string skill, vector skill_trees) { int answer = 0; int flag = 1; int cnt = 0; int check = 0; for(int i = 0; i
출처https://programmers.co.kr/learn/courses/30/lessons/12987 소스12345678910111213141516171819202122232425#include #include #include using namespace std; int solution(vector A, vector B) { int answer = 0; sort(A.begin(), A.end()); sort(B.begin(), B.end()); int res1 = 0; int k = 0; for(int i = 0; i
출처https://programmers.co.kr/learn/courses/30/lessons/42886?language=cpp 소스 123456789101112131415161718192021#include #include using namespace std; int solution(vector w){ int answer, sum = 0; sort(w.begin(), w.end()); for(int i = 0; i = w[i]){ sum = sum + w[i]; } else{ break; } } return answer = sum + 1;}Colored by Color Scriptercs
출처https://programmers.co.kr/learn/courses/30/lessons/43104 소스 123456789101112131415161718192021222324#include #include using namespace std; long long solution(int N) { long long a1 = 1; long long a2 = 1; long long a3 = 0; long long answer = 0; long long sum = 0; if (N ==1){ return 4; } else{ for(long long i = 2; i
출처 https://programmers.co.kr/learn/courses/30/lessons/42883 소스 12345678910111213141516171819202122232425262728293031323334353637383940414243444546#include #include using namespace std; string solution(string number, int k) { string answer = ""; int length = 0; length = number.length(); int cnt = 0; int len = k; int flag = 0; k = length - k; while(1){ for(int j = 0; j = k){ return answer; } } } r..
출처https://programmers.co.kr/learn/courses/30/lessons/42885 소스1234567891011121314151617181920212223242526272829303132333435#include #include using namespace std; int solution(vector p, int limit) { int answer = 0; int boat = 0; int i = 0; int j = p.size()-1; sort(p.begin(), p.end()); reverse(p.begin(), p.end()); while(1){ if(i > j){ break; } else if(i == j){ boat++; break; } if(p[i] + p[j] > limi..
출처https://programmers.co.kr/learn/courses/30/lessons/42746?language=cpp 소스 12345678910111213141516171819202122232425262728293031323334#include #include #include #include using namespace std; bool compare(string &a, string &b){ cout
출처https://programmers.co.kr/learn/courses/30/lessons/12981 소스12345678910111213141516171819202122232425262728293031323334353637383940#include #include #include using namespace std; vector solution(int n, vector words) { int flag = 0; int a = 0; int b = 0; vector answer; for(int i = 1; i
출처https://programmers.co.kr/learn/courses/30/lessons/12982 소스 123456789101112131415161718192021222324#include #include #include #include #include using namespace std; int solution(vector d, int budget) { int answer, sum = 0; sort(d.begin(), d.end()); for (int i = 0; i budget){ break; } else{ answer++; } } return answer;}Colored by Color Scriptercs