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 ...
随机推荐
- oracle存储过程中is和as区别
在存储过程(PROCEDURE)和函数(FUNCTION)中没有区别:在视图(VIEW)中只能用AS不能用IS:在游标(CURSOR)中只能用IS不能用AS.
- Vue 开发常见问题集锦
涉及技术栈 CLI: Vue-CLI UI: Element HTML: Pug(Jade) CSS: Less JavaScript: ES6 正文: polyfill 与 transform-ru ...
- AngularJS指南文档
点击查看AngularJS系列目录 转载请注明出处:http://www.cnblogs.com/leosx/ 核心概念 模板 在Angular应用当中,我们的工作就是将服务器的数据填充到客户端页面模 ...
- HDFS概述(3)————HDFS Federation
本指南概述了HDFS Federation功能以及如何配置和管理联合集群. 当前HDFS背景 HDFS主要有两层: 1.Namespace (1)包含目录,文件和块. (2)它支持所有命名空间相关的文 ...
- SQL中游标的用法
游标:是用来对表从上下每行循环取值,将值连接成为字符串.例子:对 pubs 数据库的dbo.titles 表.1.取得表中的总价格:select sum(price) from dbo.titles2 ...
- Python自学笔记-面向对象编程(Mr seven)
类的成员可以分为三大类:字段.方法和属性. 一.字段 字段包括:普通字段和静态字段,他们在定义和使用中有所区别,而最本质的区别是内存中保存的位置不同, 普通字段属于对象 静态字段属于类 二.方法 方法 ...
- ch1-vuejs基础入门(hw v-bind v-if v-for v-on v-model 应用组件简介 小案例)
1 hello world 引入vue.min.js 代码: ----2.0+版本 <div id="test"> {{str}} </div> <s ...
- python 多线程和多进程的区别 mutiprocessing theading
多线程可以共享全局变量,多进程不能.多线程中,所有子线程的进程号相同:多进程中,不同的子进程进程号不同. #!/usr/bin/python # -*- coding:utf-8 -*- import ...
- C#获取本周第一天和最后一天
DateTime nowTime = DateTime.Now; #region 获取本周第一天 //星期一为第一天 int weeknow = Convert.ToInt32(nowTime.Day ...
- 纯CSS3实现轮播图
前言 纯css3实现的轮播图效果,和JavaScript控制的相比,简单高效了很多,但是功能也更加单一,只有轮播不能手动切换. 用什么实现的呢?页面布局 + animation动画 HTML部分 &l ...