BOJ(C++) / 백준 1895 : 필터
백준 1895 : 필터 https://www.acmicpc.net/problem/1895 1895번: 필터 숫자 9개가 오름차순이나 내림차순으로 정렬되어 있을 때, 중앙값은 다섯 번째 숫자이다. 예를 들어, 1, 3, 4, 1, 2, 6, 8, 4, 10의 중앙값은 4이다. (1 ≤ 1 ≤ 2 ≤ 3 ≤ 4 ≤ 4 ≤ 6 ≤ 8 ≤ 10) 이미지 I는 www.acmicpc.net 문제 숫자 9개가 오름차순이나 내림차순으로 정렬되어 있을 때, 중앙값은 다섯 번째 숫자이다. 예를 들어, 1, 3, 4, 1, 2, 6, 8, 4, 10의 중앙값은 4이다. (1 ≤ 1 ≤ 2 ≤ 3 ≤ 4 ≤ 4 ≤ 6 ≤ 8 ≤ 10) 이미지 I는 크기가 R × C인 2차원 픽셀이다. (3 ≤ R ≤ 40, 3 ≤ C ≤ 4..
2021. 10. 10.
알고리즘(C++) / 프로그래머스 위클리 챌린지 : 전력망을 둘로 나누기
위클리 챌린지(9주차) : 전력망을 둘로 나누기 https://programmers.co.kr/learn/courses/30/lessons/86971 코딩테스트 연습 - 9주차 9 [[1,3],[2,3],[3,4],[4,5],[4,6],[4,7],[7,8],[7,9]] 3 7 [[1,2],[2,7],[3,7],[3,4],[4,5],[6,7]] 1 programmers.co.kr 코드 //프로그래머스 전력망을 둘로 나누기 #include #include #include #include #include using namespace std; int solution(int n, vector wires) { int answer = 1000001; //연결되어있는 노드 vec에 저장 vector vec(n + 1)..
2021. 10. 6.
알고리즘(C++) / 프로그래머스 level 3 : 정수 삼각형
level 3 : 정수 삼각형 https://programmers.co.kr/learn/courses/30/lessons/43105 코딩테스트 연습 - 정수 삼각형 [[7], [3, 8], [8, 1, 0], [2, 7, 4, 4], [4, 5, 2, 6, 5]] 30 programmers.co.kr 코드 //프로그래머스 정수 삼각형 #include #include #include #include using namespace std; int solution(vector triangle) { int answer = 0; for (int i = 1; i < triangle.size(); i++) { //두번째 줄부터 for (int j = 0; j < triangle[i].size(); j++) { if (..
2021. 9. 28.
알고리즘(C++) / 프로그래머스 위클리챌린지 : 최소직사각형
위클리챌린지 : 최소직사각형 https://programmers.co.kr/learn/courses/30/lessons/86491?language=cpp 코딩테스트 연습 - 8주차 [[10, 7], [12, 3], [8, 15], [14, 7], [5, 15]] 120 [[14, 4], [19, 6], [6, 16], [18, 7], [7, 11]] 133 programmers.co.kr 코드 //프로그래머스 최소직사각형 #include #include #include #include using namespace std; int solution(vector sizes) { int answer = 0; int max_col = 0; int max_row = 0; for (int i = 0; i < size..
2021. 9. 27.