최소직사각형

magicdrill·2024년 3월 11일
0

최소직사각형

#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int solution(vector<vector<int>> sizes) 
{
    int answer = 0;
    int size = sizes.size();
    vector <int> w;
    vector <int> h;
    int i;
    
    for(i = 0; i < size; i++)
    {
        w.push_back(max(sizes[i][0], sizes[i][1]));
        h.push_back(min(sizes[i][0], sizes[i][1]));
    }
    sort(w.begin(), w.end());
    sort(h.begin(), h.end());
    answer = w.back()*h.back();
    
    return answer;
}

0개의 댓글