湖南大学第十四届ACM程序设计新生杯 Dandan's lunch
Dandan's lunch
Description:
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.
Input:
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.
Output:
Outputs an integer representing the size of the bread that DanDan eventually gets.
Sample Input:
1
100000000 0 0 10000 0 0 1000
Sample Output:
10000000
题意:
给出n个三角形的三个顶点坐标,求第x大的三角形面积的2倍是多少。(详见Description)
题解:
就是叉乘求平行四边形面积,注意下绝对值。后面排个序找一下就好了。
代码如下:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
using namespace std;
typedef long long ll;
const int N = 1e5+;
int n;
int a[N];
int main(){
cin>>n;
vector <ll> vec;
for(int i=;i<=n;i++){
scanf("%d",&a[i]);
int x1,x2,x3,y1,y2,y3;
scanf("%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x3,&y3);
ll vecx1 = x2-x1,vecx2 = x3-x1;
ll vecy1 = y2-y1,vecy2 = y3-y1;
vec.push_back(vecx1*vecy2-vecy1*vecx2);
}
sort(vec.begin(),vec.end());
int tmp=a[];
sort(a+,a+n+);
for(int i=;i<=n;i++){
if(a[i]==tmp){
cout<<vec[i-];
return ;
}
}
return ;
}
湖南大学第十四届ACM程序设计新生杯 Dandan's lunch的更多相关文章
- 湖南大学第十四届ACM程序设计新生杯(重现赛)G a+b+c+d=? (16进制与LL范围)
链接:https://ac.nowcoder.com/acm/contest/338/G来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32768K,其他语言65536K6 ...
- 湖南大学第十四届ACM程序设计新生杯(重现赛)I:II play with GG(博弈论||DP)
链接:https://ac.nowcoder.com/acm/contest/338/I 来源:牛客网 题目描述 IG won the S championship and many people a ...
- 湖南大学第十四届ACM程序设计新生杯(重现赛)
RANK 0 题数 0 期末复习没有参加,补几道喜欢的题. A: AFei Loves Magic 签到 思路 :不需考虑 碰撞 直接计算最终状态即可. #include<bits/stdc ...
- 湖南大学第十四届ACM程序设计新生杯 E.Easy Problem
E.Easy Problem Description: Zghh likes number, but he doesn't like writing problem description. So h ...
- 福建工程学院第十四届ACM程序设计大赛 - E - 外传:小晋逃生记
http://www.fjutacm.com/Contest.jsp?cid=705#P4 其实想清楚了就很简单,之前想了很多种方法,以为是二分什么的,看起来就像是一个单峰函数.但是发现直接暴力一波就 ...
- 福建工程学院第十四届ACM校赛M题题解 fwt进阶,手推三进制fwt
第九集,结束亦是开始 题意: 大致意思就是给你n个3进制的数字,让你计算有多少对数字的哈夫曼距离等于i(0<=i<=2^m) 思路: 这个是一个防ak题,做法是要手推公式的fwt 大概就这 ...
- 湖南大学ACM程序设计新生杯大赛(同步赛)J - Piglet treasure hunt Series 2
题目描述 Once there was a pig, which was very fond of treasure hunting. One day, when it woke up, it fou ...
- 湖南大学ACM程序设计新生杯大赛(同步赛)A - Array
题目描述 Given an array A with length n a[1],a[2],...,a[n] where a[i] (1<=i<=n) is positive integ ...
- 湖南大学ACM程序设计新生杯大赛(同步赛)L - Liao Han
题目描述 Small koala special love LiaoHan (of course is very handsome boys), one day she saw N (N<1e1 ...
随机推荐
- Python学习:运算符
简单运算符: +(加) 两个对象相加 -(减) 从一个数中减去另一个数,如果第一个操作数不存在,则假定为零 *(乘) 给出两个数的乘积,或返回字符串重复指定次数后的结果 Eg.'haha' * 3 ...
- 关于springboot 打包问题 jar包和 war包
起因:项目开发完成 需要打包部署了 发现自己不会打包 那么开始网上学习打包? 那么怎么来打包那? 我们以前没有采用springboot 时候我们都是直接将项目打成war包形式 然后放到tomc ...
- 当我们访问不了虚拟机上ip上的web页面,是因为在window上要添加映射
在主机上添加映射步骤 1.打开C盘 注意:用nopedata++打开 保存即可!
- 听雷哥浅谈Redis
Linux下安装redis 1.下载源码,解压缩后编译源码. $ wget http://download.redis.io/releases/redis-2.8.3.tar.gz $ tar xzf ...
- jmeter接口测试--参数化
接口测试时遇到一些属性不能重复时,可以使用Random 随机函数,除此之外,也可以用用户参数 一..随机参数化 1.在jmeter工具,菜单-选项-函数助手对话框,输入数值,属性,点击生成: 2.在相 ...
- redis-Windows下安装与操作
Redis windows下安装 1.安装 (1)windows把redisbin_x32安装包放在电脑任意的盘里 (2)通过cmd找到对应目录: D\redisbin_x32 (3)开始安装 D\ ...
- C++STL——vector
一.相关定义 vector 数组 随机访问迭代器 快速随机访问元素 尾部进行快速随机地插入和删除操作 特征: 能够存放任意类型: 访问vector中的任意元素或从末尾添加元素都可以在常量级时间复杂度内 ...
- [译]10个有关SCP的命令
原文来源: https://www.tecmint.com/scp-commands-examples/ 基本语法 scp source_file_name username@destination_ ...
- C#-WinForm控制输入框只接受数字输入
背景 给导师上一节c#编写数据库应用程序的课,模拟ATM自助取款机的功能写了个winForm程序,关于金额的输入肯定是数字,因此避免输入格式不正确的数字带来异常,直接在输入时进行校验. 封装函数 C# ...
- vue2.0介绍
1.vue.js 是什么 vue(view)是一套构建用户界面的渐进式框架 Vue (pronounced /vjuː/, like view) is a progressive framework ...