链接: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. Sql 使用游标

    DECLARE data_cursor CURSOR FOR WITH T0 AS ( SELECT COUNT(f.DeptID) SubmitCount , f.DeptID FROM biz.F ...

  2. ZYNQ系列

    赛灵思公司(Xilinx)推出的行业第一个可扩展处理平台Zynq系列.旨在为视频监视.汽车驾驶员辅助以及工厂自动化等高端嵌入式应用提供所需的处理与计算性能水平.   中文名 ZYNQ系列 开发商 赛灵 ...

  3. Conference - open source drives IOT from device to edge

    Open source drives IOT from device to edge 以下都是针对IOT领域的项目: ACRN A Big Little Hypervisor for IoT Deve ...

  4. Linux架构之Nginx Web基础1

    第41章 Nginx Web基础入门 41.1 Nginx部署 41.1.1 Nginx的安装方式   源码编译 官方仓库 epel仓库 优点 规范 安装简单 安装简单   便于管理 配置易读   缺 ...

  5. cf2c(模拟退火 步长控制

    https://www.luogu.org/problem/CF2C 题意:在平面上有三个没有公共部分的圆,求平面上一点使得到三个圆的切线的夹角相等.(若没答案满足条件,则不打印 思路:可用模拟退火算 ...

  6. maven 提取jar包 依赖及打包排除

    <properties> <project.targetDir>D:\jar</project.targetDir> <project.targetServe ...

  7. Docker之安装缺省指令

    Docker 中有些指令不存在,需要额外的安装,这里做下安装记录. 更新软件源中的所有软件列表 apt-get update 安装 ifconfig apt install net-tools 安装 ...

  8. 前端之form表单与css(1)

    目录 一.form表单 1.1表单的属性 1.2input 1.2.1form表单提交数据的两种方式 1.3select标签 1.4label标签 1.5textarea多行文本标签 二.CSS 2. ...

  9. 【leetcode】1026. Maximum Difference Between Node and Ancestor

    题目如下: Given the root of a binary tree, find the maximum value V for which there exists different nod ...

  10. python实现Restful服务 (基于flask)(1)

    参考:https://www.jianshu.com/p/6ac1cab17929 参考:https://www.cnblogs.com/alexyuyu/p/6243362.html 参考:http ...