D Dandan's lunch
链接: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.
备注:
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的更多相关文章
- 湖南大学第十四届ACM程序设计新生杯 Dandan's lunch
Dandan's lunch Description: As everyone knows, there are now n people participating in the competiti ...
- 湖南大学第十四届ACM程序设计新生杯(重现赛)
RANK 0 题数 0 期末复习没有参加,补几道喜欢的题. A: AFei Loves Magic 签到 思路 :不需考虑 碰撞 直接计算最终状态即可. #include<bits/stdc ...
- HDU4807 Lunch Time(费用流变种)
题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=4807 Description The campus of Nanjing Universit ...
- 水题 ZOJ 3875 Lunch Time
题目传送门 /* 水题:找排序找中间的价格,若有两个,选价格大的: 写的是有点搓:) */ #include <cstdio> #include <iostream> #inc ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Lunch Time
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5499 The 12th Zhejiang Provincial ...
- 第十二届浙江省大学生程序设计大赛-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 ...
- hiho1092_have lunch together
题目 两个人从同一个点出发,在一个餐厅中寻找两个相邻的座位,需要是的从出发点到达座位的距离总和最短.题目链接: Have Lunch Together 最短路程,一开始以为要用dijkstra ...
- Codeforces Gym 100637B B. Lunch 找规律
B. Lunch Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100637/problem/B Des ...
- build/envsetup.sh内lunch解析
........ # 测试device是否存在且是一个目录 并且 只查找device目录4层以上的子目录,名字为vendorsetup.sh 并且 将命令执行的错误报告直接送往回收站 不显示在屏幕上 ...
随机推荐
- Maya2019下载安装与激活
目录 1. 更多推荐 2. 下载地址 2.1. OneDrive 2.2. Window (64位) 2.3. MAC_OSX 3. 安装激活教程 1. 更多推荐 其他Maya版本的下载与激活:htt ...
- pgtksh -- PostgreSQL Tcl/Tk shell 客户端
SYNOPSIS pgtksh [filename [argument...]] DESCRIPTION 描述 pgtksh 是一个带有 PostgreSQL 数据库访问函数扩展的 Tcl/Tk sh ...
- 07.SUSE Linux 系统本地yum源配置
SUSE Linux 系统 1.新建本地源存储目录root@suse:mkdir /mnt/SUSE_LOCAL_SOURCE 2.创建zypper本地源root@suse:zypper ar fil ...
- 二、搭建Swagger
1.新建.netCore webapi项目 2.安装swagger ,通过 Package Manager 控制台:Install-Package Swashbuckle.AspNetCore 3.修 ...
- 解决 INSTALL FAILED CONFLICTING PROVIDER
1.现象: 2.产生原因 INSTALL FAILED CONFLICTING PROVIDER 产生的原因通常是因为系统中已经安装的apk的provider中的authorities相同了,导致在安 ...
- Test 3.27 T2 旅行
Description FGD 想从成都去上海旅游.在旅途中他希望经过一些城市并在那里欣赏风景,品尝风味小吃或者做其他的有趣的事情.经过这些城市的顺序不是完全随意的,比如说 FGD 不希望在刚吃过一顿 ...
- Task5.NB_SVM_LDA
参考:https://blog.csdn.net/u013710265/article/details/72780520 贝叶斯公式就一行: P(Y|X)=P(X|Y)P(Y)P(X) 而它其实是由以 ...
- 命令——tr
文本处理工具命令——tr 一帮助说明 TR() User Commands TR() NAME tr - translate or delete characters SYNOPSIS tr [OPT ...
- onLayout初始化裁剪信息
在EasyConstraintLayout中初始化LayoutParamsData的paths @Override protected void onLayout(boolean changed, i ...
- jmeter(二十):Logic Controller:逻辑控制器(上)
逻辑控制器用来控制采样器(samplers)的执行顺序,根据实际需要定制执行规则.在控制器层级下面的所有的采样器都会当做一个整体,执行时也会一起被执行. Logic Controller种类: 以上L ...