알고리즘

C++ 알고리즘 - 백준 7568 덩치

마루설아 2024. 12. 29. 14:15

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

 

#include <iostream>
#include <vector>
#define endl "\n"

using namespace std;

class human {
public:
	int weight;
	int height;
	int rank;
};

int main(void) {
	// C++ Init
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int input;
	int weight, height;
	human h;
	vector<human> v;

	cin >> input;
	for (int i = 0; i < input; i++) {
		cin >> weight >> height;
		h.weight = weight;
		h.height = height;
		h.rank = 1;
		v.push_back(h);
	}

	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v.size(); j++) {
			if (i == j) continue;
			if (v[i].height < v[j].height && v[i].weight < v[j].weight) v[i].rank++;
		}
	}

	for (int i = 0; i < v.size(); i++) {
		cout << v[i].rank << " ";
	}
}