Notice
Recent Posts
Recent Comments
Today
Total
01-11 11:00
Link
๊ด€๋ฆฌ ๋ฉ”๋‰ด

Partially Committed

[์œ„ํด๋ฆฌ ์ฑŒ๋ฆฐ์ง€] ์ตœ์†Œ์ง์‚ฌ๊ฐํ˜• ๋ณธ๋ฌธ

๐Ÿ”ฅ Algorithm || ๋ฌธ์ œํ’€์ด/PS

[์œ„ํด๋ฆฌ ์ฑŒ๋ฆฐ์ง€] ์ตœ์†Œ์ง์‚ฌ๊ฐํ˜•

WonderJay 2022. 7. 4. 21:48
728x90
๋ฐ˜์‘ํ˜•
SMALL

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

 

์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ์ตœ์†Œ์ง์‚ฌ๊ฐํ˜•

[[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 <string>
#include <vector>
#include <algorithm>

using namespace std;

void rotate_namecard(vector<int>& namecard)
{
    swap(namecard[0], namecard[1]);
}

int get_area(int a, int b)
{
    return a*b;
}

int solution(vector<vector<int>> sizes) {

    int answer = 0;
    int m_row = 0, m_col = 0;

    vector<int> width;
    vector<int> height;

    for (auto& ele : sizes)
    {
        if (ele[0] > ele[1])
            rotate_namecard(ele);
    } 

    for (auto& ele : sizes)
    {
        if (ele[0] > m_col)
            m_col = ele[0];
        if (ele[1] > m_row)
            m_row = ele[1];
    }

    answer = get_area(m_col, m_row);


    return answer;
}

 

 

[C++]

728x90
๋ฐ˜์‘ํ˜•
LIST
Comments