출처: https://bumcrush.tistory.com/182 [맑음때때로 여름]
https://www.acmicpc.net/problem/7568
7568번: 덩치
우리는 사람의 덩치를 키와 몸무게, 이 두 개의 값으로 표현하여 그 등수를 매겨보려고 한다. 어떤 사람의 몸무게가 x kg이고 키가 y cm라면 이 사람의 덩치는 (x,y)로 표시된다. 두 사람 A 와 B의 덩�
www.acmicpc.net
#include <iostream>
using namespace std;
const int MAX = 50 + 1;
pair<int, int> people[MAX];
int arr[MAX];
int main()
{
int num;
cin >> num;
for (int i = 1; i <= num; i++)
{
cin >> people[i].first >> people[i].second;
}
for (int i = 1; i <= num; i++)
{
for (int j = 1; j <= num; j++)
{
if (i == j)
continue;
if (people[i].first < people[j].first && people[i].second < people[j].second)
{
arr[i] += 1;
}
}
}
for (int i = 1; i <= num; i++)
cout << arr[i] + 1 << " ";
}
brute force문제이기는 하나 구현 문제에 더 가까운 것 같기도 하다. 이 문제는 사실상 크게 어려운 점은 없었다. pair가 아닌 2차원 배열을 통해서도 풀 수 있는 문제였지만 오랜만에 pair가 써보고 싶어서 그렇게 풀었다.
백준 1748 수 이어 쓰기 1(brute force) (0) | 2020.07.18 |
---|---|
백준 1966 프린터 큐(brute force) (0) | 2020.07.18 |
백준 4641 Doubles(brute force) (0) | 2020.07.16 |
백준 2858 기숙사 바닥(brute force) (0) | 2020.07.16 |
백준 2217 로프(greedy approach) (0) | 2020.07.14 |
댓글 영역