【经典问题】maximum subset sum of vectors
AtCoder Beginner Contest 139 Task F Engines
题目大意
给定 $n$ 个二维向量,从中选出若干个,使得它们的和的模最大。
分析
这是一个经典问题,还有一种提法是:
给定 $n$ 个二维向量 $v_1, v_2, \dots, v_n$,求一组系数 $a_1, a_2, \dots, a_n$($0 \le a_i \le 1$)使得 $\sum_{i = 1}^{n} a_i v_i$ 的模最大。
容易证明:对于最优解,$a_i$ 要么是 1 要么是 0;于是归约到选择一个最优子集的问题。
可以证明,最优解满足下列两个性质:
- The set of vectors in an optimal solution using a minimal number of vectors must all lie in an open half-plane. 包含向量数目最少的最优解中,所有向量都在一个开的半平面中
如果加上「所选的向量都在一个开的半平面中」这个限制,我们立即可以推论出,若先把所有向量按极角排序,则所选的那些向量必定是其中连续的一段。换言之,
- 对于包含向量数目最少的最优解,其中的向量按极角排序后是连续的一段。The vectors in the optimal solution using a minimal number of vectors are contiguous when ordered according to angle circularly.
References
https://math.stackexchange.com/q/730611/538611
【经典问题】maximum subset sum of vectors的更多相关文章
- Light OJ 1272 Maximum Subset Sum 高斯消元 最大XOR值
版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/u011686226/article/details/32337735 题目来源:problem=12 ...
- [leetcode]124. Binary Tree Maximum Path Sum二叉树最大路径和
Given a non-empty binary tree, find the maximum path sum. For this problem, a path is defined as any ...
- PAT Advanced 1007 Maximum Subsequence Sum
题目 1007 Maximum Subsequence Sum (25分) Given a sequence of K integers { N1, N2, ..., N**K }. A contin ...
- [LeetCode] Binary Tree Maximum Path Sum 求二叉树的最大路径和
Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. ...
- [leetcode]Binary Tree Maximum Path Sum
Binary Tree Maximum Path Sum Given a binary tree, find the maximum path sum. The path may start and ...
- LeetCode(124) Binary Tree Maximum Path Sum
题目 Given a binary tree, find the maximum path sum. For this problem, a path is defined as any sequen ...
- LeetCode124:Binary Tree Maximum Path Sum
题目: Given a binary tree, find the maximum path sum. The path may start and end at any node in the tr ...
- leetcode 124. Binary Tree Maximum Path Sum
Given a binary tree, find the maximum path sum. For this problem, a path is defined as any sequence ...
- [lintcode] Binary Tree Maximum Path Sum II
Given a binary tree, find the maximum path sum from root. The path may end at any node in the tree a ...
随机推荐
- 批量插入数据@Insert
// 批量插入数据 @Insert("<script>" + "insert into index_kline (currency_id, currency, ...
- 【学习】eclipse自动提示+自动补全
解决代码的自动提示问题: 1.打开 Eclipse -> Window -> Perferences 2.找到Java 下的 Editor 下的 Content Assist , 右边出现 ...
- js移动端触屏事件
移动端触屏滑动的效果其实就是图片轮播,在PC的页面上很好实现,绑定click和mouseover等事件来完成.但是在移动设备上,要实现这种轮播的效果,就需要用到核心的touch事件.处理touch事件 ...
- Mac 10.15 关闭SIP
升级Mac后SIP开启了,根目录不能创建文件了 关闭 sip,终端输入 sudo mount -uw / 在我们开发过程中,有时候我们安装一些工具软件需要将文件拷贝到系统限制更改的文件夹中,甚至有时需 ...
- 从Ubuntu 14.04 LTS版升级到Ubuntu 16.04 LTS
Ubuntu 16.04 (Xerial Xerus) Long Term Support版于最近发布了.要想了解它的新功能和新特性,就必须升级或安装这个新系统. 本文讲述怎样一步步从Ubuntu ...
- nginx目录及配置语法
一.Nginx安装目录 1.查看安装目录. 采用yum的方式安装,其实都是安装的一个一个的 pm 包,故可采用如下命令查看 rpm -ql nginx 遵循了 rpm 包管理规范. 2.安装目录详解 ...
- springboot启动报错:Failed to configure a DataSource
一.背景 springboot的出现,让项目搭建变得更方便快捷,同时简化掉很多的样板化配置代码,提高开发效率. 通过idea生成springboot项目,启动报错:Failed to configur ...
- flask 学习(三)
继续flask的学习.尝试了使用程序context这一部分: 而在hello.py文档的旁边发现新出现了hello.pyc,看来运行过程中也被编译成字节码文件了,也不清楚是在哪个步骤的,留着后面研究. ...
- JVM内存模型及配置参数
JVM 分为堆.栈.方法区.程序计数器.本地方法栈 栈内存存放局部变量表.操作栈.动态链接.方法出口等信息 1. 局部变量表存放了编译期可知的各种基本数据类型(boolean.byte.char.s ...
- [iOS]UIWebView返回和NSURLErrorDomain-999
1.UIWebView实现返回不崩溃: -(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)r ...