BOJ7568

김현민·2021년 1월 13일
0

Algorithm

목록 보기
1/126
post-thumbnail

BOJ7568. 덩치

문제


코드

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[])
{

    cin.tie(NULL);
    ios::sync_with_stdio(false);
    int n, x, y, rank = 1;

    cin >> n;
    pair<int, int> p;
    vector<pair<int, int>> v;
    int ch[n];
    for (int i = 0; i < n; i++)
    {
        cin >> x >> y;
        v.push_back(make_pair(x, y));
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (i == j)
                continue;
            if (v[i].first < v[j].first && v[i].second < v[j].second)
            {
                rank++;
            }
        }

        ch[i] = rank;
        rank = 1;
    }

    for (int i = 0; i < n; i++)
    {
        cout << ch[i] << endl;
    }

    return 0;
}
  • 몸무게와 키의 한쌍으로 벡터에 넣는다
  • for문으로 비교대상을 옮겨가며 키와 몸무게 둘다 크면 rank++
  • 1년전에 못푼 문제였는데 금방 해결했다. 😁
profile
Jr. FE Dev

0개의 댓글