<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Binary Search on 111qqz's blog</title><link>https://111qqz.com/en/tags/binary-search/</link><description>Recent content in Binary Search on 111qqz's blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>© 2015-2026 111qqz</copyright><lastBuildDate>Fri, 14 Apr 2017 12:25:16 +0000</lastBuildDate><atom:link href="https://111qqz.com/en/tags/binary-search/index.xml" rel="self" type="application/rss+xml"/><item><title>leetcode162. Find Peak Element (O(lgn)复杂度寻找峰值)</title><link>https://111qqz.com/en/post/acm-icpc/2017/2017-04-14-leetcode-162/</link><pubDate>Fri, 14 Apr 2017 12:25:16 +0000</pubDate><guid>https://111qqz.com/en/post/acm-icpc/2017/2017-04-14-leetcode-162/</guid><description>&lt;p&gt;A peak element is an element that is greater than its neighbors.&lt;/p&gt;
&lt;p&gt;Given an input array where &lt;code&gt;num[i] ≠ num[i+1]&lt;/code&gt;, find a peak element and return its index.&lt;/p&gt;
&lt;p&gt;The array may contain multiple peaks, in that case return the index to any one of the peaks is fine.&lt;/p&gt;</description></item><item><title>leetcode 33. Search in Rotated Sorted Array (无重复数的旋转数组找定值)</title><link>https://111qqz.com/en/post/acm-icpc/2017/2017-04-13-leetcode-33-search-in-rotated-sorted-array/</link><pubDate>Thu, 13 Apr 2017 06:29:37 +0000</pubDate><guid>https://111qqz.com/en/post/acm-icpc/2017/2017-04-13-leetcode-33-search-in-rotated-sorted-array/</guid><description>&lt;p&gt;Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.&lt;/p&gt;
&lt;p&gt;(i.e., &lt;code&gt;0 1 2 4 5 6 7&lt;/code&gt; might become &lt;code&gt;4 5 6 7 0 1 2&lt;/code&gt;).&lt;/p&gt;</description></item><item><title>leetcode 34. Search for a Range (二分，找到一段值为tar的区间)</title><link>https://111qqz.com/en/post/acm-icpc/2017/2017-04-13-leetcode-34-search-for-a-range/</link><pubDate>Thu, 13 Apr 2017 05:34:45 +0000</pubDate><guid>https://111qqz.com/en/post/acm-icpc/2017/2017-04-13-leetcode-34-search-for-a-range/</guid><description>&lt;p&gt;Given an array of integers sorted in ascending order, find the starting and ending position of a given target value.&lt;/p&gt;
&lt;p&gt;Your algorithm&amp;rsquo;s runtime complexity must be in the order of &lt;em&gt;O&lt;/em&gt;(log &lt;em&gt;n&lt;/em&gt;).&lt;/p&gt;</description></item><item><title>leetcode 81. Search in Rotated Sorted Array II (有重复元素的旋转数组找给定值)</title><link>https://111qqz.com/en/post/acm-icpc/2017/2017-04-05-leetcode-81-search-in-rotated-sorted-array-ii/</link><pubDate>Wed, 05 Apr 2017 13:17:51 +0000</pubDate><guid>https://111qqz.com/en/post/acm-icpc/2017/2017-04-05-leetcode-81-search-in-rotated-sorted-array-ii/</guid><description>&lt;p&gt;Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.&lt;/p&gt;
&lt;p&gt;(i.e., &lt;code&gt;0 1 2 4 5 6 7&lt;/code&gt; might become &lt;code&gt;4 5 6 7 0 1 2&lt;/code&gt;).&lt;/p&gt;</description></item><item><title>求旋转数组最小值（二分）</title><link>https://111qqz.com/en/post/acm-icpc/2017/2017-03-12-e6978be8bdace695b0e7bb84efbc88e4ba8ce58886efbc89/</link><pubDate>Sun, 12 Mar 2017 13:19:16 +0000</pubDate><guid>https://111qqz.com/en/post/acm-icpc/2017/2017-03-12-e6978be8bdace695b0e7bb84efbc88e4ba8ce58886efbc89/</guid><description>&lt;p&gt;题意：把一个数组最开始的若干个元素搬到数组的末尾，我们称之为数组的旋转。
输入一个非递减排序的数组的一个旋转，输出旋转数组的最小元素。
例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转，该数组的最小值为1。&lt;/p&gt;</description></item><item><title>leetcode 74. Search a 2D Matrix</title><link>https://111qqz.com/en/post/acm-icpc/2017/2017-03-09-leetcode-74-search-a-2d-matrix/</link><pubDate>Thu, 09 Mar 2017 11:14:05 +0000</pubDate><guid>https://111qqz.com/en/post/acm-icpc/2017/2017-03-09-leetcode-74-search-a-2d-matrix/</guid><description>&lt;p&gt;&lt;a href="https://leetcode.com/problems/search-a-2d-matrix/?tab=Description" target="_blank" rel="noreferrer"&gt;题目链接&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;题意：给一个二维数组。。。每一行每一列都分别递增。。问某个value是否出现过。。。&lt;/p&gt;</description></item><item><title>leetcode 235. Lowest Common Ancestor of a Binary Search Tree（求一个BST中某两个节点LCA）</title><link>https://111qqz.com/en/post/acm-icpc/2017/2017-02-22-leetcode-235-lowest-common-ancestor-of-a-binary-search-tree/</link><pubDate>Wed, 22 Feb 2017 13:22:08 +0000</pubDate><guid>https://111qqz.com/en/post/acm-icpc/2017/2017-02-22-leetcode-235-lowest-common-ancestor-of-a-binary-search-tree/</guid><description>&lt;p&gt;&lt;a href="https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/?tab=Description" target="_blank" rel="noreferrer"&gt;题目链接&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;题意：求一个BST中某两个节点LCA&amp;hellip;.&lt;/p&gt;
&lt;p&gt;思路：卧槽。。。竟然求LCA&amp;hellip;直接想到的显然是Tarjan的方法或者。。。RMQ+DFS。。。但是感觉。。。leetcode怎么可能考算法。。。。于是想到。。。可以从BST下手。。。&lt;/p&gt;</description></item><item><title>codeforces 381 div 2 D. Alyona and a tree(二分+前缀和)</title><link>https://111qqz.com/en/post/acm-icpc/2016/2016-11-28-cf740d/</link><pubDate>Mon, 28 Nov 2016 07:07:00 +0000</pubDate><guid>https://111qqz.com/en/post/acm-icpc/2016/2016-11-28-cf740d/</guid><description>&lt;p&gt;&lt;a href="http://codeforces.com/contest/740/problem/D" target="_blank" rel="noreferrer"&gt;题目链接&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;d:题意：一棵树，给出边权和点权，定义点v控制点u，当且仅当u是v的子树中的点，并且dis(u,v)&amp;lt;=a[u]，其中dis(u,v)为点u到点v路径上的边权和，a[u]为点u的点权，现在问对于每个节点v，其能控制的点有多少个。&lt;/p&gt;</description></item><item><title>codeforces #609 F. Frogs and mosquitoes (线段树+二分)</title><link>https://111qqz.com/en/post/acm-icpc/2016/2016-09-20-codeforces-609-f-frogs-and-mosquitoes-e7babfe6aeb5e6a091e4ba8ce58886/</link><pubDate>Tue, 20 Sep 2016 17:48:18 +0000</pubDate><guid>https://111qqz.com/en/post/acm-icpc/2016/2016-09-20-codeforces-609-f-frogs-and-mosquitoes-e7babfe6aeb5e6a091e4ba8ce58886/</guid><description>&lt;p&gt;&lt;a href="http://codeforces.com/problemset/problem/609/F" target="_blank" rel="noreferrer"&gt;题目链接&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;题意：n只青蛙，第i只位于x[i],舌头长度为t[i]。m只蚊子，第i只蚊子所在位置为p[i],蚊子的大小为b[i]。&lt;/p&gt;</description></item><item><title>poj 3579 Median (尺取法+二分)</title><link>https://111qqz.com/en/post/acm-icpc/2016/2016-09-19-poj-3579/</link><pubDate>Mon, 19 Sep 2016 16:54:21 +0000</pubDate><guid>https://111qqz.com/en/post/acm-icpc/2016/2016-09-19-poj-3579/</guid><description>&lt;p&gt;题意：给出n个数，两两做差的绝对值，共有m=n*(n-1)/2个，问其中的中位数是多少。特别地，当m为偶数的时候，中位数为第m/2个。&lt;/p&gt;</description></item><item><title>poj 2456 Aggressive cows (二分)</title><link>https://111qqz.com/en/post/acm-icpc/2016/2016-09-19-poj2456/</link><pubDate>Mon, 19 Sep 2016 15:15:57 +0000</pubDate><guid>https://111qqz.com/en/post/acm-icpc/2016/2016-09-19-poj2456/</guid><description>&lt;p&gt;&lt;a href="http://poj.org/problem?id=2456" target="_blank" rel="noreferrer"&gt;题目链接&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;题意：给出n个x轴上的坐标点，选取其中c个，问c个之中任意两个点的最小距离最大是多少。&lt;/p&gt;</description></item><item><title>seerc 2014 Circle of digits (二分+后缀数组)</title><link>https://111qqz.com/en/post/acm-icpc/2016/2016-08-27-seerc-2014-circle-of-digits-e4ba8ce58886e5908ee7bc80e695b0e7bb84/</link><pubDate>Sat, 27 Aug 2016 07:37:23 +0000</pubDate><guid>https://111qqz.com/en/post/acm-icpc/2016/2016-08-27-seerc-2014-circle-of-digits-e4ba8ce58886e5908ee7bc80e695b0e7bb84/</guid><description>&lt;p&gt;&lt;a href="http://acm.hust.edu.cn/vjudge/contest/130303#problem/B" target="_blank" rel="noreferrer"&gt;题目链接&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;题意：把一个长度为n的只由数字构成的串分成k个不为空的字串，使得最大的串最小（大小是说串所对应的十进制数的大小）&lt;/p&gt;</description></item><item><title>whust 2016 warm up G ||codeforces 689C. Mike and Chocolate Thieves</title><link>https://111qqz.com/en/post/acm-icpc/2016/2016-07-18-cf689c/</link><pubDate>Mon, 18 Jul 2016 12:29:16 +0000</pubDate><guid>https://111qqz.com/en/post/acm-icpc/2016/2016-07-18-cf689c/</guid><description>&lt;p&gt;&lt;a href="http://codeforces.com/problemset/problem/689/C" target="_blank" rel="noreferrer"&gt;cf689C&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;题意：给出一个m。。问恰好使得不超过某个n的a*b^3（a,b是正整数）的方案数为m的n是多少。。。&lt;/p&gt;</description></item><item><title>BZOJ 1614: [Usaco2007 Jan]Telephone Lines架设电话线 (二分+spfa)</title><link>https://111qqz.com/en/post/acm-icpc/2016/2016-05-22-bzoj-1614/</link><pubDate>Sun, 22 May 2016 13:09:49 +0000</pubDate><guid>https://111qqz.com/en/post/acm-icpc/2016/2016-05-22-bzoj-1614/</guid><description>&lt;h2 class="relative group"&gt;1614: [Usaco2007 Jan]Telephone Lines架设电话线
 &lt;div id="1614-usaco2007-jantelephone-lines架设电话线" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#1614-usaco2007-jantelephone-lines%e6%9e%b6%e8%ae%be%e7%94%b5%e8%af%9d%e7%ba%bf" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;Time Limit: 5 Sec  Memory Limit: 64 MB
Submit: 1325  Solved: 570
[&lt;a href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=1614" target="_blank" rel="noreferrer"&gt;Submit&lt;/a&gt;][&lt;a href="http://www.lydsy.com/JudgeOnline/problemstatus.php?id=1614" target="_blank" rel="noreferrer"&gt;Status&lt;/a&gt;][&lt;a href="http://www.lydsy.com/JudgeOnline/bbs.php?id=1614" target="_blank" rel="noreferrer"&gt;Discuss&lt;/a&gt;]&lt;/p&gt;</description></item><item><title>poj 2452 Sticks Problem (rmq+二分，需要返回最值位置)</title><link>https://111qqz.com/en/post/acm-icpc/2016/2016-05-18-poj2452/</link><pubDate>Wed, 18 May 2016 05:40:40 +0000</pubDate><guid>https://111qqz.com/en/post/acm-icpc/2016/2016-05-18-poj2452/</guid><description>&lt;p&gt;&lt;a href="http://poj.org/problem?id=2452" target="_blank" rel="noreferrer"&gt;poj2452题目链接&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;题意：给你一组数a[n]，求满足a[i] &amp;lt; a[k] &amp;lt; a[j] (i &amp;lt;= k &amp;lt;= j)的最大的j-i。&lt;/p&gt;</description></item><item><title>BZOJ 1650: [Usaco2006 Dec]River Hopscotch 跳石子 (二分)</title><link>https://111qqz.com/en/post/acm-icpc/2016/2016-04-11-bzoj-1650/</link><pubDate>Mon, 11 Apr 2016 12:07:02 +0000</pubDate><guid>https://111qqz.com/en/post/acm-icpc/2016/2016-04-11-bzoj-1650/</guid><description>&lt;h2 class="relative group"&gt;1650: [Usaco2006 Dec]River Hopscotch 跳石子
 &lt;div id="1650-usaco2006-decriver-hopscotch-跳石子" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#1650-usaco2006-decriver-hopscotch-%e8%b7%b3%e7%9f%b3%e5%ad%90" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;Time Limit: 5 Sec  Memory Limit: 64 MB
Submit: 440  Solved: 290
[&lt;a href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=1650" target="_blank" rel="noreferrer"&gt;Submit&lt;/a&gt;][&lt;a href="http://www.lydsy.com/JudgeOnline/problemstatus.php?id=1650" target="_blank" rel="noreferrer"&gt;Status&lt;/a&gt;][&lt;a href="http://www.lydsy.com/JudgeOnline/bbs.php?id=1650" target="_blank" rel="noreferrer"&gt;Discuss&lt;/a&gt;]&lt;/p&gt;</description></item><item><title>BZOJ 1639: [Usaco2007 Mar]Monthly Expense 月度开支 (二分)</title><link>https://111qqz.com/en/post/acm-icpc/2016/2016-04-08-bzoj-1639/</link><pubDate>Fri, 08 Apr 2016 08:11:10 +0000</pubDate><guid>https://111qqz.com/en/post/acm-icpc/2016/2016-04-08-bzoj-1639/</guid><description>&lt;h2 class="relative group"&gt;1639: [Usaco2007 Mar]Monthly Expense 月度开支
 &lt;div id="1639-usaco2007-marmonthly-expense-月度开支" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#1639-usaco2007-marmonthly-expense-%e6%9c%88%e5%ba%a6%e5%bc%80%e6%94%af" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;Time Limit: 5 Sec  Memory Limit: 64 MB
Submit: 767  Solved: 381
[&lt;a href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=1639" target="_blank" rel="noreferrer"&gt;Submit&lt;/a&gt;][&lt;a href="http://www.lydsy.com/JudgeOnline/problemstatus.php?id=1639" target="_blank" rel="noreferrer"&gt;Status&lt;/a&gt;][&lt;a href="http://www.lydsy.com/JudgeOnline/bbs.php?id=1639" target="_blank" rel="noreferrer"&gt;Discuss&lt;/a&gt;]&lt;/p&gt;</description></item><item><title>codeforces 617 C. Tourist's Notes (二分)</title><link>https://111qqz.com/en/post/acm-icpc/2016/2016-03-30-cf617e-2/</link><pubDate>Wed, 30 Mar 2016 15:24:59 +0000</pubDate><guid>https://111qqz.com/en/post/acm-icpc/2016/2016-03-30-cf617e-2/</guid><description>&lt;p&gt;&lt;a href="https://111qqz.com/en/post/acm-icpc/2016/2016-02-15-cf617e/" &gt;题目链接&lt;/a&gt;
题意：有n天的旅行，但是只剩下了m天的旅行记录，记录格式为d[i],h[d[i]]，表示第i个记录是第d[i]天的，高度为h[d[i]],相邻两天的高度之差的绝对值不超过1.问满足以上条件的最大的h是多少。无解输出impossible.
思路：为了练习二分。 二分高度，然后check是否合法。注意边界，所以可以添加两个点。&lt;/p&gt;</description></item><item><title>codeforces #339 div2 D</title><link>https://111qqz.com/en/post/acm-icpc/2016/2016-02-20-cf613b/</link><pubDate>Sat, 20 Feb 2016 12:59:29 +0000</pubDate><guid>https://111qqz.com/en/post/acm-icpc/2016/2016-02-20-cf613b/</guid><description>&lt;p&gt;&lt;a href="http://codeforces.com/contest/613/problem/B" target="_blank" rel="noreferrer"&gt;http://codeforces.com/contest/613/problem/B&lt;/a&gt;
题意：有n个技能，初始每个技能的level为a[i]，每个技能最大level为A(不妨称为满级技能)，设满级技能个数为maxnum,最小的技能level为minval,问如何将m个技能点分配到n个技能上使得cf&lt;em&gt;maxsum+cm&lt;/em&gt;minval (n&amp;lt;=1E5,a[i],A&amp;lt;=1E9,cf,cm&amp;lt;=1E3,m&amp;lt;=1E15)&lt;/p&gt;</description></item><item><title>codeforces 479D. Long Jumps</title><link>https://111qqz.com/en/post/acm-icpc/2015/2015-04-08-cf479d/</link><pubDate>Wed, 08 Apr 2015 11:52:00 +0000</pubDate><guid>https://111qqz.com/en/post/acm-icpc/2015/2015-04-08-cf479d/</guid><description>&lt;p&gt;&lt;a href="http://codeforces.com/problemset/problem/479/D" target="_blank" rel="noreferrer"&gt;http://codeforces.com/problemset/problem/479/D&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;题意是说有一把尺子，本身有一些刻度，然后需要测量x和y，问最少需要添加多少个刻度，如果需要，这些刻度分别添加在什么位置。&lt;/p&gt;</description></item></channel></rss>