HDU6127Hard challenge
Hard challenge
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 1305 Accepted Submission(s): 557
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
/*
* @Author: lyuc
* @Date: 2017-08-15 15:31:46
* @Last Modified by: lyuc
* @Last Modified time: 2017-08-17 09:01:32
*/
/*
题意:给你n个点,每个点都有权值,并且每两个点之间都有一条线,这条线的权值就是端点的权值之积,问你从过原点画一条直线,
使得穿过直线的权值之和最大 思路:这里有一个推论,假如有四个已经按照极角排好序的点,a,b,c,d 有条直线在 b c之间,那么两两之间直线权值和为:
ac+ad+bc+bd=a*(c+d)+b*(c+d)=(a+b)*(c+d); 这样题目就出来了,首先将所有的点按照极角排序,然后遍历所有的点
,比较得到的每个点
*/
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h> #define LL long long
#define INF 0x3f3f3f3f
#define pi acos(-1.0)
#define MAXN 50005 using namespace std; struct Point{
int x,y;
LL val;
double cur;
}point[MAXN];
int t,n;
LL lres,rres;
LL res; inline bool cmp(Point a,Point b){
return a.cur<b.cur;
} inline void init(){
lres=;
rres=;
res=;
} int main(){
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
scanf("%d",&t);
while(t--){
init();
scanf("%d",&n);
for(int i=;i<n;i++){
scanf("%d%d%lld",&point[i].x,&point[i].y,&point[i].val);
if(point[i].x==){//如果在y轴
if(point[i].y>=)
point[i].cur=pi/;
else
point[i].cur=-pi/;
}else{
point[i].cur=atan(point[i].y*1.0/point[i].x);
}
if(point[i].x>=){
rres+=point[i].val;
}else{
lres+=point[i].val;
}
}
sort(point,point+n,cmp);
res=lres*rres;
for(int i=;i<n;i++){
if(point[i].x>=){
rres-=point[i].val;
lres+=point[i].val;
}else{
lres-=point[i].val;
rres+=point[i].val;
}
res=max(res,lres*rres);
}
printf("%lld\n",res);
}
return ;
}
HDU6127Hard challenge的更多相关文章
- CF Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined)
1. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) B. Batch Sort 暴力枚举,水 1.题意:n*m的数组, ...
- The Parallel Challenge Ballgame[HDU1101]
The Parallel Challenge Ballgame Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ( ...
- bzoj 2295: 【POJ Challenge】我爱你啊
2295: [POJ Challenge]我爱你啊 Time Limit: 1 Sec Memory Limit: 128 MB Description ftiasch是个十分受女生欢迎的同学,所以 ...
- acdream.LCM Challenge(数学推导)
LCM Challenge Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Submit ...
- [codeforces 235]A. LCM Challenge
[codeforces 235]A. LCM Challenge 试题描述 Some days ago, I learned the concept of LCM (least common mult ...
- iOS 网络请求中的challenge
这里有一篇文章,请阅读,感谢作者!http://blog.csdn.net/kmyhy/article/details/7733619 当请求的网站有安全认证问题时,都需要通过 [[challenge ...
- CodeForces Gym 100500A A. Poetry Challenge DFS
Problem A. Poetry Challenge Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/10 ...
- 手势识别(一)--手势基本概念和ChaLearn Gesture Challenge
以下转自: http://blog.csdn.net/qq1175421841/article/details/50312565 像点击(clicks)是GUI平台的核心,轻点(taps)是触摸平台的 ...
- 大规模视觉识别挑战赛ILSVRC2015各团队结果和方法 Large Scale Visual Recognition Challenge 2015
Large Scale Visual Recognition Challenge 2015 (ILSVRC2015) Legend: Yellow background = winner in thi ...
随机推荐
- Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/SpringStruts]]
今天启动Tomcat时候遇到了这个问题 Failed to start component [StandardEngine[Catalina].StandardHost[localhost].Stan ...
- [android游戏开发初学]简单的游戏框架
这两天,没事想学习游戏开发,看了一些资料之后准备开始.为了将来编码方便,先写了一个简单的游戏框架方便自己以后做练习用. 如果以后没有什么特殊的需求--比如opengl什么的,会尽量用这个简单框架来实现 ...
- android自定义动画
前一篇说了实现过程,这次来写一个自己简单实现的3d动画 先来属性声明配置,方便使用xml 文件来定制动画 <!-- 有些类型其实是没必要的,只是实例代码,为了更具有代表性 --> < ...
- ACM学习之路___HDU 1385(带路径保存的 Floyd)
Description These are N cities in Spring country. Between each pair of cities there may be one trans ...
- 复选框demo
本篇文章是关于复选框的,有2种形式:1.全选.反选由2个按钮实现:2.全选.反选由一个按钮实现. <!DOCTYPE html> <html> <head> < ...
- 常见sql技巧
一.一些常见的SQL实践 (1)负向条件查询不能使用索引 select * from order where status!=0 and stauts!=1 not in/not exists都不是好 ...
- SSM之整合Redis
Redis安装与使用 第一步当然是安装Redis,这里以Windows上的安装为例. 首先下载Redis,可以选择msi或zip包安装方式 zip方式需打开cmd窗口,在解压后的目录下运行redis- ...
- shell查找指定时间段内的文件
#!/bin/bash#20170905 输入参数格式echo "显示"$1"的备份文件"date_0=$1date_1=`expr $date_0 + 1`d ...
- 关于Java里面File类创建txt文件重复???
private JButton getOpenButton() { if (openButton == null) { openButton = new JButton(); openButton.s ...
- 深入理解C# 静态类与非静态类、静态成员的区别 [转载]
静态类 静态类与非静态类的重要区别在于静态类不能实例化,也就是说,不能使用 new 关键字创建静态类类型的变量.在声明一个类时使用static关键字,具有两个方面的意义:首先,它防止程序员写代码来实例 ...