U E D R , A S I H C RSS

Birthday Cake/허준수

~cpp
#include <iostream>
#include <vector>

using namespace std;

struct Cherry {
	int x;
	int y;
	double gradient;
};

vector<Cherry> Gradient;

void input(int x, int y)
{
	Cherry temp;
	temp.x = x;
	temp.y = y;
	temp.gradient= (double)y/x;
	Gradient.push_back(temp);
}

void process(int num)
{
	for(int k = 0; k<Gradient.size()-1; k++)
	{
		for(int j = k+1; j<Gradient.size(); j++) { 
			Cherry temp;
			if(Gradient[k].gradient > Gradient[j].gradient) {
				temp.gradient = Gradient[j].gradient;
				Gradient[j].gradient = Gradient[k].gradient;
				Gradient[k].gradient = temp.gradient;
			}
		}
	}

	int b = (Gradient[num/2].x + Gradient[num/2 + 1].x)*(-1);
	int a = Gradient[num/2].y + Gradient[num/2 + 1].y;
	cout << a << " " << b <<endl;
     Gradient.clear();
}

int main()
{
	int numCherry, i;
	int x, y;
	while(true) {
		cin >> numCherry;
		if(numCherry == 0)
			break;
		for(i = 0; i<2*numCherry; i++) {
			cin >> x >> y;
			input(x, y);
		}
		process(numCherry);
	}
	return 0;
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:22:37
Processing time 0.0158 sec