[프로그래머스 / C++] 최소직사각형

Taegang Yun·2023년 9월 6일
1

https://school.programmers.co.kr/learn/courses/30/lessons/86491

#include <string>
#include <vector>

using namespace std;

int solution(vector<vector<int>> sizes) {
    int bigger, max_w = 0;
    int lesser, max_h = 0;
    
    for(int i = 0 ; i < sizes.size(); i++)
    {
        bigger = sizes[i][0] > sizes[i][1] ? sizes[i][0] : sizes[i][1];
        lesser = bigger == sizes[i][0] ? sizes[i][1] : sizes[i][0];
        if (bigger > max_w) max_w = bigger;
        if (lesser > max_h) max_h = lesser;
    }
    return max_w * max_h;
}

1트 성공!

profile
언젠간 전문가가 되겠지

0개의 댓글

관련 채용 정보