W를 명함의 가로, 세로 중 큰 값으로 보고, H를 작은값으로 보고 풀었다.
#include <algorithm>
#include <vector>
using namespace std;
int solution(vector<vector<int>> sizes) {
int W = 0, H = 0;
for (int i = 0; i < sizes.size(); i++)
{
if (W < max(sizes[i][0], sizes[i][1]))
W = max(sizes[i][0], sizes[i][1]);
if (H < min(sizes[i][0], sizes[i][1]))
H = min(sizes[i][0], sizes[i][1]);
}
return W * H;
}'Coding_Test 연습 > Programmers' 카테고리의 다른 글
| [프로그래머스] (C++) LV1 부족한 금액 계산하기 (0) | 2022.04.25 |
|---|---|
| [프로그래머스] (C++) LV1 나머지가 1이 되는 수 찾기 (0) | 2022.04.25 |
| [프로그래머스] (C++) LV1 2016년 (0) | 2022.04.24 |
| [프로그래머스] (C++) LV1 두 개 뽑아서 더하기 (0) | 2022.04.23 |
| [프로그래머스] (C++) LV1 예산 (0) | 2022.04.21 |