컴퓨터공학/알고리듬 풀이

백준-기하:직사각형과 삼각형 9063 대지

cyphen156 2025. 2. 24. 13:18

대지

여러개의 좌표를 입력받아 가장 넓은 범위를 갖는 직사각형을 구하는 프로그램

제약사항

  • 0 < Inputs <= 100,000
  • -10,000 <= Point <= 10,000

주의 사항

없다.

CPP풀이

대지_9063.cpp

/**
 * 백준 대지_9063
 * 여러개의 좌표를 입력받아 가장 넓은 범위를 갖는 직사각형을 구하는 프로그램
 * 
 * 제한사항
 *****************************************
 * 0 < Inputs <= 100,000                 *
 * -10,000 <= Point <= 10,000            *
 *****************************************
 *
 *
 *
 * 주의
 * 없다.
 * 
 * 풀이시간 0분
 */


#include <iostream>

using namespace std;

int main(void)
{
    int inputs;
    cin >> inputs;

    
    int minX = 10001, minY = 10001, maxX =  - 10001, maxY = - 10001;
    for (int i = 0; i < inputs; ++i)
    {
        int inputX, inputY;
        cin >> inputX >> inputY;
        if (inputs == 1)
        {
            cout << 0 << endl;
            return 0;
        }
        if (inputX < minX)
        {
            minX = inputX;
        }
        if (inputX > maxX)
        {
            maxX = inputX;
        }

        if (inputY < minY)
        {
            minY = inputY;
        }
        if (inputY > maxY)
        {
            maxY = inputY;
        }
    }

    cout << (maxX - minX) * (maxY - minY) << endl; 
    return 0;
}

모든 예제 코드의 소스파일은 제 개인 깃허브 레포지토리 에 있습니다.

 

Workspace/알고리듬 풀이 at main · cyphen156/Workspace

Studying . Contribute to cyphen156/Workspace development by creating an account on GitHub.

github.com