hdu61272017杭电多校第七场1008Hard challenge
Hard challenge
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 1487 Accepted Submission(s): 352
on the plane, and the ith
points has a value vali,
and its coordinate is (xi,yi).
It is guaranteed that no two points have the same coordinate, and no two points makes the line which passes them also passes the origin point. For every two points, there is a segment connecting them, and the segment has a value which equals the product of
the values of the two points. Now HazelFan want to draw a line throgh the origin point but not through any given points, and he define the score is the sum of the values of all segments that the line crosses. Please tell him the maximum score.
denoting the number of test cases.
For each test case:
The first line contains a positive integer n(1≤n≤5×104).
The next n lines,
the ith
line contains three integers xi,yi,vali(|xi|,|yi|≤109,1≤vali≤104).
A single line contains a nonnegative integer, denoting the answer.
2
1 1 1
1 -1 1
3
1 1 1
1 -1 10
-1 0 100
1100
Statistic | Submit | Clarifications | Back
题意:平面上一些点,两点连线的价值等于点的价值的乘积,定义经过原点的一条直线的值等于它所相交的线段的价值的总和。
思路:现对这些点进行极角排序,给直线分为两部分,s1和s2分别表示两部分的价值。设排序后的第一个点(分到左边部分即从第一个点右边一点开始)开始逆时针旋转,离开一个点的时候,s1减去那个点的值,s2加上那个点的值;另设一个变量维护当前的扫描始终是180°。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define ll long long
const double pi=acos(-1.0);
const double eps=1e-8;
int T;
int n;
struct Point{
int x,y;
int val;
double ang;
}point[200000+50];
double angle(Point a){
double x=abs(a.x);
double y=abs(a.y);
if (a.x>0&&a.y>0) return atan(y/x)*180.0/pi;
else if (a.x<0&&a.y>0) return 180.0-atan(y/x)*180.0/pi;
else if (a.x<0&&a.y<0) return 180.0+atan(y/x)*180.0/pi;
else if (a.x>0&&a.y<0) return 360.0-atan(y/x)*180.0/pi;
else if (a.x==0){
if (a.y>0) return 90;
else if (a.y<0) return 270;
else return -1;
}
else if (a.y==0){
if (a.x>0) return 0;
else if (a.x<0) return 180;
else return -1;
}
return -1;
}
bool cmp(Point a,Point b){
return a.ang<b.ang;
}
int main(){
// freopen("1.txt","r",stdin);
scanf("%d",&T);
while (T--){
scanf("%d",&n);
ll sum=0;
for (int i=1;i<=n;i++){
scanf("%d %d %d",&point[i].x,&point[i].y,&point[i].val);
sum+=point[i].val;
point[i].ang=angle(point[i]);
}
sort(point+1,point+n+1,cmp);
for (int i=n+1;i<=n+n;i++){
point[i]=point[i-n];
point[i].ang+=360;
}
ll s1=0,s2=0;
int r;
for (int i=1;i<=n;i++){
if (point[i].ang-point[1].ang<180){
s1+=point[i].val;
}
else{
r=i;
break;
}
}
s2=sum-s1;
int l=1;
ll ans=0;
while (l<=n){
ans=max(ans,s1*s2);
s1-=point[l].val;
s2+=point[l].val;
l++;
while (r<=2*n&&point[r].ang-point[l].ang<180){
s1+=point[r].val;
s2-=point[r].val;
r++;
}
}
printf("%lld\n",ans);
}
}
hdu61272017杭电多校第七场1008Hard challenge的更多相关文章
- 杭电多校第七场 1010 Sequence(除法分块+矩阵快速幂)
Sequence Problem Description Let us define a sequence as below f1=A f2=B fn=C*fn-2+D*fn-1+[p/n] Your ...
- 杭电多校第七场-J-Sequence
题目描述 Let us define a sequence as belowYour job is simple, for each task, you should output Fn module ...
- 2017杭电多校第七场1011Kolakoski
Kolakoski Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others) Tota ...
- 2017杭电多校第七场1005Euler theorem
Euler theorem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others) ...
- 2019杭电多校第七场 HDU - 6656 Kejin Player——概率&&期望
题意 总共有 $n$ 层楼,在第 $i$ 层花费 $a_i$ 的代价,有 $pi$ 的概率到 $i+1$ 层,否则到 $x_i$($x_i \leq 1$) 层.接下来有 $q$ 次询问,每次询问 $ ...
- 【杭电多校第七场】A + B = C
原题: Given a,b,c, find an arbitrary set of x,y,z such that a*10^x+b*10^y=c*10^z and 0≤x,y,z≤10^6. 给你三 ...
- [2019杭电多校第七场][hdu6656]Kejin Player
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6656 题意为从i级花费a元有p的概率升到i+1级,有1-p的概率降到x级(x<i),查询从L级升 ...
- [2019杭电多校第七场][hdu6655]Just Repeat
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6655 题意是说两个人都有一些带有颜色的牌,两人轮流出牌,但是不能出对面出过的颜色的牌,最后谁不能出牌谁 ...
- [2019杭电多校第七场][hdu6651]Final Exam
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6651 题意:n个科目,总共m分,通过一科需要复习花费科目分数+1分钟,在不知道科目分数的情况下,问最少 ...
随机推荐
- 前端开发:JQuery(1)
JQuery DOM文档加载的步骤: 1. 解析HTML结构: 2. 加载外部脚本和样式: 3. 解析并执行脚本代码: 4. DOM树构建完成: 5. 加载图片等外部文件: 6. 页面加载完成: JS ...
- [ C++ 快速高精度模板 ] [ BigN类 ] 大整数类 高精度 模板 BigInt FFT 快速傅里叶变换
[原创 转载请注明]瞎写的,如果代码有错,或者各位大佬有什么意见建议,望不吝赐教 更新日志: 对于规模较小的整数乘法使用$$O(n^2)$$方法,提高速度 modify()和operator[]的bu ...
- 可持久化KMP
一开始有一空串,n次操作,每次在串末尾加入一个字符问最小循环节.要求在线与可持久化. 如果只是在线的话那是很简单的,答案是!!$i-fail[i]$,其中$fail[i]$是KMP中的失配函数. 但如 ...
- 洛谷——P3379 【模板】最近公共祖先(LCA)
P3379 [模板]最近公共祖先(LCA) 题目描述 如题,给定一棵有根多叉树,请求出指定两个点直接最近的公共祖先. 输入输出格式 输入格式: 第一行包含三个正整数N.M.S,分别表示树的结点个数.询 ...
- 洛谷——P1007 独木桥
P1007 独木桥 题目背景 战争已经进入到紧要时间.你是运输小队长,正在率领运输部队向前线运送物资.运输任务像做题一样的无聊.你希望找些刺激,于是命令你的士兵们到前方的一座独木桥上欣赏风景,而你留在 ...
- some 算法
矩阵变换:: 请用一条语句将: arr = [[1, 2, 3, 'a'], [4, 5, 6, 'b'], [7, 8, 9, 'c']] 转换装置矩阵为: [[1, 4, 7], [2, 5, 8 ...
- Android: Mac无法找到Android SDK问题
通过brew cask install android-sdk后,Intellij Idea中设置Android SDK路径失败,解决方法如下: /usr/local/Caskroom/android ...
- ppt五种经典字体组合
在做ppt中常常为使用哪种字体而头疼,如今将ppt的经典字体附上.希望对大家有帮助 五种经典的字体组合 标题字体 正文字体 使用场合 方正综艺简体 微软雅黑 课题汇报.咨询报告.学术研讨等正式场合 方 ...
- 鸟哥的Linux私房菜-----1、Linux是什么与怎样学习Linux
- 视频生成 量产 win 转 linux ffmpeg linux 安装 对批量视频的尽可能短时间生成
环境准备 Welcome to aliyun Elastic Compute Service! [root@mytest ~]# pip install baidu-aip Looking in in ...