湖南大学第十四届ACM新生赛--D---Dandan's lunch

Dandan’s lunch

题目描述
As everyone knows, there are now n people participating in the competition. It was finally
lunch time after 3 hours of the competition. Everyone brought a triangular bread. When they
were going to eat bread, some people found that they solved more problems than others, but
their bread was smaller than others. They thought it was very unfair. In this case, they will forcibly
exchange bread with the other party (may be exchanged many times, someone can still exchange
with others after being exchanged if the above conditions are satisfied, the other party can not
refuse). The description of the bread is given by the coordinates of the three vertices of the triangle. The size of the bread is twice the size of the triangle area, ensuring that there are no two breads
of the same size, and the number of problems each person makes is different. Dandan is also one of the contestants. Now he knows the number of problems solved by
each person and the description of the bread they bring. Now he wants to know that after all the
exchanges are over (That is, there can be no more exchanges between any two people), The size
of the bread he can get.

输入描述
The first line gives an integer n, which indicates the number of people who participated in
the competition. Lines 2~n+1, each line gives 7 integers separated by spaces such as:
num x1 y1 x2 y2 x3 y3
num represents the number of the ith personal problem solving. (x1, y1) (x2, y2) (x3, y3)
represents the coordinates of the three points of the bread of the triangle with the i-th person. ensure that three points are not in the same line. Notice that the second line (the first person) represents Dandan’s information. Data guarantee: 0

输出描述
Outputs an integer representing the size of the bread that DanDan eventually gets

示例输入
1
100000000 0 0 10000 0 0 1000
输出
10000000

输入
4
3 0 0 1 0 0 1
1 0 0 2 0 0 2
2 0 0 3 0 0 3
4 0 0 4 0 0 4
输出
9

提示
For the first case: there’s only Dandan alone. For the second case: Dandan solved three problems, ranking second. Ranking first can get the
biggest bread, so he can get the second largest bread.

解:

在经过了很多次交换后,丹丹排在第几名,就拿到第几大的面包,因此,我们只需将每个人的做题数,和面包的面积分别进行排序,再根据丹丹的排名,来选出第几大的面包,即为所求的最终答案。
PS:本题面包面积并未直接给出,而是给出三角形面包三个顶点的坐标,因此我们可以利用向量的叉乘公式来算出面包的面积。
但有一点要注意,用叉乘公式算出来的值不一定是正数,有可能是负数,因此,我们得对所有负数结果去绝对值!!xwx 傻fufu作者就载在这上面了

#include
#include
using namespace std;
int main()
{
	long long m,n,i,j,t,x1,y1,x2,y2,x3,y3,u1,u2,v1,v2;
	scanf("%lld",&n);
    long long a[100001],b[100001];//分别存解题数和面包面积
    for(i=0;i

你可能感兴趣的:(萌新笔记)