链接:https://ac.nowcoder.com/acm/contest/338/D
来源:牛客网

题目描述

    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<n<=1e5,0<=num<1e9, -1e8<x1, x2, x3, y1, y2, y3<1e8.

输出描述:

Outputs an integer representing the size of the bread that DanDan eventually gets.
示例1

输入

复制

1
100000000 0 0 10000 0 0 1000

输出

复制

10000000

说明

There's only Dandan alone.
示例2

输入

复制

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

说明

Dandan solved three problems, ranking second. Ranking first can get the biggest bread, so he can get the second largest bread.

备注:

1e5=100000
1e8=100000000
1e9=1000000000 优化一下
显然,最终的局面为:解题数目排行第i的人会获得第i大的面包(解题数目最多的人一定可以
获得最大的面包,第二可以获得第二大的面包,依次类推…)。
故只需知道到Dandan的解题数目在所有人中的排名rk,然后输出第rk大的面包大小即可。
(Ⅰ)获取排名--排序:sort()。
(Ⅱ)已知三点坐标计算三角形的面积?
①底×高/--可能会有精度误差(?)
②向量叉乘:
如图三角形的面积为1 a × b ,故三角形的面积的两倍为 a × b 。

 
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
int t;
long long x;
scanf("%d",&t);
long long sum[100000+10];
long long n[100000+10];
long long a,b,c,d,e,f;
for(int i = 0; i<t; i++)
{ scanf("%lld %lld %lld %lld %lld %lld %lld",&n[i],&a,&b,&c,&d,&e,&f);
sum[i] = (a*d+c*f+e*b-a*f-c*b-e*d);
if(sum[i]<0)
sum[i] = -sum[i];
x = n[0];
}
sort(n,n+t);
sort(sum,sum+t);
for(int i = 0; i < t; i++)
{
if(x==n[i])
{
printf("%lld\n",sum[i]);
}
} }

显然,最终的局面为:解题数目排行第i的人会获得第i大的面包(解题数目最多的人一定可以获得最大的面包,第二可以获得第二大的面包,依次类推…)。故只需知道到Dandan的解题数目在所有人中的排名rk,然后输出第rk大的面包大小即可。(Ⅰ)获取排名--排序:sort()。(Ⅱ)已知三点坐标计算三角形的面积?①底×高/2--可能会有精度误差(?)②向量叉乘:如图三角形的面积为12a × b ,故三角形的面积的两倍为 a × b 。

D Dandan's lunch的更多相关文章

  1. 湖南大学第十四届ACM程序设计新生杯 Dandan's lunch

    Dandan's lunch Description: As everyone knows, there are now n people participating in the competiti ...

  2. 湖南大学第十四届ACM程序设计新生杯(重现赛)

    RANK  0 题数 0 期末复习没有参加,补几道喜欢的题. A: AFei Loves Magic  签到 思路 :不需考虑 碰撞 直接计算最终状态即可. #include<bits/stdc ...

  3. HDU4807 Lunch Time(费用流变种)

    题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=4807 Description The campus of Nanjing Universit ...

  4. 水题 ZOJ 3875 Lunch Time

    题目传送门 /* 水题:找排序找中间的价格,若有两个,选价格大的: 写的是有点搓:) */ #include <cstdio> #include <iostream> #inc ...

  5. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Lunch Time

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5499 The 12th Zhejiang Provincial ...

  6. 第十二届浙江省大学生程序设计大赛-Lunch Time 分类: 比赛 2015-06-26 14:30 5人阅读 评论(0) 收藏

    Lunch Time Time Limit: 2 Seconds Memory Limit: 65536 KB The 999th Zhejiang Provincial Collegiate Pro ...

  7. hiho1092_have lunch together

    题目 两个人从同一个点出发,在一个餐厅中寻找两个相邻的座位,需要是的从出发点到达座位的距离总和最短.题目链接: Have Lunch Together     最短路程,一开始以为要用dijkstra ...

  8. Codeforces Gym 100637B B. Lunch 找规律

    B. Lunch Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100637/problem/B Des ...

  9. build/envsetup.sh内lunch解析

    ........ # 测试device是否存在且是一个目录 并且 只查找device目录4层以上的子目录,名字为vendorsetup.sh 并且 将命令执行的错误报告直接送往回收站 不显示在屏幕上 ...

随机推荐

  1. python时间测量

    使用自定义装饰器测量时间 def test_time(func): def inner(*args, **kw): t1 = datetime.datetime.now() print('开始时间:' ...

  2. Linux 实操(root密码重置 无法上网 安装xrdp)

    一个是显示器显示不咋地,一个是想远程连接Linux,这样就可以放到下面机房去了.所以想安装一个远程桌面链接.从网上搜了搜,好多.安装的时候需要root权限,但是密码忘了.好吧,开始捣鼓root密码 按 ...

  3. stream benchmark 介绍

    英文原版 https://www.cs.virginia.edu/stream/ref.html FAQ中有关于STREAM_ARRAY_SIZE NTIME OFFSET STREAM_TYPE的设 ...

  4. Solr从数据库导入数据(DIH)

    一. 数据导入(DataImportHandler-DIH) DIH 是solr 提供的一种针对数据库.xml/HTTP.富文本对象导入到solr 索引库的工具包.这里只针对数据库做介绍. A.准备以 ...

  5. bzoj5118 Fib数列2 二次剩余+矩阵快速幂

    题目传送门 https://lydsy.com/JudgeOnline/problem.php?id=5118 题解 这个题一看就是不可做的样子. 求斐波那契数列的第 \(n\) 项,\(n \leq ...

  6. 06.队列、python标准库中的双端队列、迷宫问题

    class QueueUnderflow(ValueError): """队列为空""" pass class SQueue: def __ ...

  7. Jenkins配置git/github 插件的ssh key

    参考来源:http://jingyan.baidu.com/article/a65957f4f0acc624e67f9bc1.html 方式一:本地需要生成公私钥文件,git/github中新建ssh ...

  8. Ubuntu 14.04 虚拟机配置固定ip地址

    Ubuntu 14.04 虚拟机配置固定ip地址: 虚拟机用的NAT方式配置: 1.虚拟机: 虚拟机→设置→网络适配器→NAT模式: 2.虚拟机:编辑→虚拟网络编辑器→更改设置→选择NAT→填入子网I ...

  9. 使用linkedlist封装简单的先进先出队列

    创建一个类Queue代表队列(先进先出),添加add(Object obj) 及get()方法, 并添加main()方法进行验证 思路: 使用LinkedList实现队列,在向LinkedList中添 ...

  10. 使用sys.dm_exec_cached_plans监控存储过程性能

    讨论了如何使用sys.dm_exec_query_stats动态管理视图(dmv ).本文将以SQL Server 2005为例,讨论如何利用dmv信息来判断tsql的性能优劣.在这篇文章中将继续我有 ...