![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
二分
Frontier_Setter
这个作者很懒,什么都没留下…
展开
-
USACO 6.3.1 Fence Rails 01多背包问题(BS+IDDFS)
http://train.usaco.org/usacoprob2?a=NaWWtjt80VA&S=fence8题目大意:有N(1-50)块原木,要切成R(1-1023)块长度(1-128)可重复的木板,并不一定所有的木板都能被切出来,求能够交货的最大木板数量错误想法:我一开始正着想觉得有种网络流的感觉,把每个原木看作一个有限容量的节点,和每个木板结点以无限容量的管道连接,木板结点在和汇点...原创 2018-02-12 21:12:32 · 604 阅读 · 0 评论 -
[LeetCode] (medium) 673. Number of Longest Increasing Subsequence
https://leetcode.com/problems/number-of-longest-increasing-subsequence/Given an unsorted array of integers, find the number of longest increasing subsequence.Example 1:Input: [1,3,5,4,7]Outpu...原创 2019-05-31 11:17:55 · 111 阅读 · 0 评论 -
[LeetCode] (medium) 222. Count Complete Tree Nodes
https://leetcode.com/problems/count-complete-tree-nodes/Given acompletebinary tree, count the number of nodes.Note:Definition of a complete binary tree fromWikipedia:In a complete binary tr...原创 2019-03-20 22:17:01 · 140 阅读 · 0 评论 -
[LeetCode] (medium) 81. Search in Rotated Sorted Array II
https://leetcode.com/problems/search-in-rotated-sorted-array-ii/Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e.,[0,0,1,2,2,5,6]might become[...原创 2019-02-28 14:17:18 · 106 阅读 · 0 评论 -
[LeetCode] (medium) 378. Kth Smallest Element in a Sorted Matrix
https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the mat...原创 2019-02-18 20:30:23 · 199 阅读 · 0 评论 -
[LeetCode] (medium) 287. Find the Duplicate Number
https://leetcode.com/problems/find-the-duplicate-number/Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number mus...转载 2019-02-18 13:40:42 · 100 阅读 · 0 评论 -
[LeetCode] (medium) 162. Find Peak Element
https://leetcode.com/problems/find-peak-element/A peak element is an element that is greater than its neighbors.Given an input array nums, where nums[i] ≠ nums[i+1], find a peak element and retur...原创 2019-02-16 19:56:47 · 94 阅读 · 0 评论 -
[LeetCode] (medium) 34. Find First and Last Position of Element in Sorted Array
https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/Given an array of integers nums sorted in ascending order, find the starting and ending position of a given tar...原创 2019-02-04 22:07:06 · 86 阅读 · 0 评论 -
[LeetCode] (medium) 33. Search in Rotated Sorted Array
https://leetcode.com/problems/search-in-rotated-sorted-array/Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,1,2,4,5,6,7] might become [4,5...原创 2019-02-04 21:47:33 · 623 阅读 · 0 评论 -
USACO 6.4.2 Electric Fences 三分算法
http://train.usaco.org/usacoprob2?a=gY0nBCREMEt&S=fence3题目大意:用两点坐标形式给出平面内F条线段(平面为(0,0)到(100,100), F小于等于150),求出平面内一点使得从该点连向所有线段的距离最小(可以和线段上任意一点相连)且平面内的各种线可以任意交叉解题思路:一开始查到了模拟退火的解法,吓了我一跳,后来查到了这个亲民的解法...原创 2018-02-15 02:24:32 · 286 阅读 · 0 评论 -
[LeetCode] (medium) 658. Find K Closest Elements
https://leetcode.com/problems/find-k-closest-elements/Given a sorted array, two integerskandx, find thekclosest elements toxin the array. The result should also be sorted in ascending order. ...原创 2019-05-29 11:19:11 · 136 阅读 · 0 评论