나의 브을로오그으

[c++] 7568번 : 덩치 본문

알고리즘/BaekJoon

[c++] 7568번 : 덩치

__jhp_+ 2022. 5. 4. 13:53

https://www.acmicpc.net/problem/7568

 

7568번: 덩치

우리는 사람의 덩치를 키와 몸무게, 이 두 개의 값으로 표현하여 그 등수를 매겨보려고 한다. 어떤 사람의 몸무게가 x kg이고 키가 y cm라면 이 사람의 덩치는 (x, y)로 표시된다. 두 사람 A 와 B의 덩

www.acmicpc.net

#include <iostream>
#include <vector>
#include <utility>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	vector<pair<int, int>> ranks;
	int w = 0;
	int h = 0;

	int n = 0;
	cin >> n;
	ranks.reserve(n + 1);
	for (int i = 0; i < n; ++i)
	{
		cin >> w >> h;
		ranks.push_back(pair<int, int>(w, h));
	}

	for (int i = 0; i < n; ++i)
	{
		int rank = 1;
		for (int j = 0; j < n; ++j)
		{
			int rankCount = 0;
			rankCount += ranks[i].first < ranks[j].first ? 1 : 0;
			rankCount += ranks[i].second < ranks[j].second ? 1 : 0;
			rank += rankCount == 2 ? 1 : 0;
		}
		cout << rank << ' ';
	}

	return 0;
}

'알고리즘 > BaekJoon' 카테고리의 다른 글

[c++] 10250번 : ACM 호텔  (0) 2022.05.04
[c++] 9012번 : 괄호  (0) 2022.05.04
[c++] 4949번 : 균형잡힌 세상  (0) 2022.04.30
[c++] 4153번 : 직각삼각형  (0) 2022.04.30
[c++] 2869번 : 달팽이는 올라가고 싶다  (0) 2022.04.30