链接: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. C#.Net 调用Java的Web Service

    首先,得有一个web service地址:http://www.baiduc.om/XXServices?wsdl 然后在.net 项目中添加Web引用,并把地址给它输进去 第三.编码: using ...

  2. [Usaco2007 Jan]Telephone Lines架设电话线(最短路,二分)

    [Usaco2007 Jan]Telephone Lines架设电话线 Description FarmerJohn打算将电话线引到自己的农场,但电信公司并不打算为他提供免费服务.于是,FJ必须为此向 ...

  3. 使用GDB调试产生多进程的程序

    如果一个进程fork了多个进程,这时使用GBD工具对程序进行调试会如何呢? 实际上,GDB 没有对多进程程序调试提供直接支持.例如,使用GDB调试某个进程,如果该进程fork了子进程,GDB会继续调试 ...

  4. js关于小数点失精算法修正0.07*100竟然=7.000000000000001

    转发 https://blog.csdn.net/iteye_13003/article/details/82645716

  5. 前端每日实战:32# 视频演示如何用纯 CSS 创作六边形按钮特效

    效果预览 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/xjoOeM 可交互视频教程 此视频 ...

  6. Codeforces 892E Envy

    问题描述 小Q正在玩一个叠塔的游戏,游戏的目标是叠出尽可能高的塔.在游戏中,一共有n张矩形卡片,其中第i张卡片的 长度为a_i,宽度为b_i.小Q需要把所有卡片按一定顺序叠成一座塔,要求对于任意一个矩 ...

  7. Oracle12c修改时区

    Oacle12c支持可插入数据库(PDB)在一个统一的数据库(CDB)中具有不同的字符集.时区文件版本和数据库时区. 出于性能原因,Oracle建议将数据库时区设置为UTC(0:00),因为不需要转换 ...

  8. Linux系统下安装jenkins使用

    jenkins 2.190.1 yum 安装 devops一梦千年 发布时间:10-0916:28 jenkins 2.190.1 yum 安装记录 安装环境: 所需安装包: https://pkg. ...

  9. drf 搜索功能

    from django_filters.rest_framework import DjangoFilterBackend from rest_framework import viewsets fr ...

  10. Django2 + python3 上传图片

    . ├── db.sqlite3 ├── manage.py ├── myImg │   ├── __init__.py │   ├── __pycache__ │   │   ├── __init_ ...