https://www.acmicpc.net/problem/7568
7568번: 덩치
우리는 사람의 덩치를 키와 몸무게, 이 두 개의 값으로 표현하여 그 등수를 매겨보려고 한다. 어떤 사람의 몸무게가 x kg이고 키가 y cm라면 이 사람의 덩치는 (x, y)로 표시된다. 두 사람 A 와 B의 덩
www.acmicpc.net
부르스 포스 알고리즘으로
그냥 전체 순회를 하면 된다.
// 백준 7568 부르스포스 문제
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
typedef struct student
{
int weight;
int height;
} student;
int main()
{
int num;
cin >> num;
vector<int> ranking(num, 1);
vector<student> students(num);
for (int a = 0; a < num; a++)
{
cin >> students[a].height;
cin >> students[a].weight;
}
for (int a = 0; a < num; a++)
{
for (int b = 0; b < num; b++)
{
if (students[a].height < students[b].height && students[a].weight < students[b].weight)
{
ranking[a] += 1;
}
}
}
for (int a = 0; a < ranking.size(); a++)
{
cout << ranking[a] << " ";
}
}
나는 그냥 구조체로 만들어서 비교했다.
반응형
'알고리즘 > 백준' 카테고리의 다른 글
(백준 1269) 대칭 차집합 (0) | 2022.06.29 |
---|---|
(백준 14425) 문자열 집합 (0) | 2022.06.27 |
(백준 10815) 숫자 카드 (0) | 2022.06.26 |
(백준 10814) 나이순 정렬 (0) | 2022.06.25 |
백준 1436 영화감독 숀 (0) | 2022.06.17 |