
二分
文章平均质量分 63
xuanweiace
一个热爱算法竞赛的弱校ACMer路过。青大本,浙大硕,方向后端开发,菜鸡一枚,奋斗ing...
展开
-
给不会调用C++STL库中二分函数lower_bound,upper_bound,binary_search同学的一些话!
lower_bound算法返回第一个大于等于给定值所在的位置。设置两个指针start和last,其中start指向数组的起始位置,last指向数组末尾位置之后的位置。当start和last指向相同位置时循环结束。mid指向[start,last)区间的中间位置,当中间位置元素值大于等于给定val时,说明第一个大于等于val值在mid位置的左边,更新last为mid。当中间位置元素值小于给定的v...原创 2019-11-02 21:58:23 · 203 阅读 · 0 评论 -
【CodeForces - 722D】Generating Sets(二分,贪心)
题干:You are given a setYofndistinctpositive integersy1, y2, ..., yn.SetXofndistinctpositive integersx1, x2, ..., xnis said togeneratesetYif one can transformXtoYby applying som...原创 2019-10-31 20:51:32 · 290 阅读 · 0 评论 -
【CodeForces - 701D】As Fast As Possible(二分,模拟,数学公式)
题干:On vacationsnpupils decided to go on excursion and gather all together. They need to overcome the path with the lengthlmeters. Each of the pupils will go with the speed equal tov1. To get to...原创 2019-10-25 12:53:56 · 357 阅读 · 0 评论 -
【POJ - 2976】【ZOJ - 3068】【SCU - 2992】Dropping tests (01分数规划)
题干:In a certain course, you take n tests. If you get ai out of bi questions correct on test i, your cumulative average is defined to be.Given your test scores and a positive integer k, determine...原创 2019-02-18 22:50:32 · 297 阅读 · 0 评论 -
【牛客 - 330F】Applese 的QQ群(拓扑排序,二分)
题干: Applese 有一个QQ群。在这个群中,大家互相请教问题。如 b 向 a 请教过问题,就把 a 叫做是 b 的"老板"。这样一个群中就会有很多老板。同时规定:如果 a 是 b 的老板,b 是 c 的老板,那么 a 也是 c 的老板。为了不破坏群里面和谐交流的氛围,Applese 定了一个群规:不允许出现 a 既是 b 的老板, b 又是 a 的老板。你需要帮助 Apple...原创 2019-01-29 22:03:05 · 315 阅读 · 0 评论 -
【UVA - 1335】Beijing Guards (贪心,二分)
题干:题目大意:有n个人为成一个圈,其中第i个人想要r[i]种不同的礼物,相邻的两个人可以聊天,炫耀自己的礼物。如果两个相邻的人拥有同一种礼物,则双方都会很不高兴,问最少需要多少种不同的礼物才能满足所有人的需求,假设每种礼物有无限多个。 n<=100000解题报告:http://www.cnblogs.com/kickit/p/7619889.htmlhttp://www...原创 2018-12-09 13:29:09 · 308 阅读 · 0 评论 -
【CodeForces - 349C】Mafia(思维模拟,优秀的二分)
题干:One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how ...原创 2018-11-09 22:18:32 · 789 阅读 · 0 评论 -
【CodeForces - 244B】Undoubtedly Lucky Numbers (dfs打表 + 二分)
题干:Polycarpus loves lucky numbers. Everybody knows that lucky numbers are positive integers, whose decimal representation (without leading zeroes) contain only the lucky digits x and y. For example,...原创 2018-11-08 16:39:18 · 1299 阅读 · 0 评论 -
【CodeForces - 589F】Gourmet and Banquet (贪心,思维,二分)
题干:A gourmet came into the banquet hall, where the cooks suggested n dishes for guests. The gourmet knows the schedule: when each of the dishes will be served.For i-th of the dishes he knows two i...原创 2018-10-30 21:58:47 · 297 阅读 · 0 评论 -
【POJ - 2398】Toy Storage (计算几何,二分找位置,叉积,点和直线的位置关系)
题干: Mom and dad have a problem: their child, Reza, never puts his toys away when he is finished playing with them. They gave Reza a rectangular box to put his toys in. Unfortunately, Reza is rebel...原创 2018-10-27 00:22:35 · 205 阅读 · 0 评论 -
【牛客 - 318F】关于我转生变成史莱姆这档事(二分,搜索)
题干:有一天,利姆鲁在这个世界最重要的人静被魔王带走,并将其困在一个n*n的迷宫内的某一处,迷宫的每个格子都可能有一只魔物,魔物的攻击力为a[i][j],因而利姆鲁只有当攻击力大于等于a[i][j]才能通过这个方格,否则就只能绕道(只能朝上下左右四个方向)而行。 为了拯救静,利姆鲁决定勇闯迷宫! 现在利姆鲁站在(sx,sy)处,静在(ex,ey)处,为了保证自己能够成功拯救静,...原创 2019-02-16 00:11:07 · 514 阅读 · 0 评论 -
【牛客 - 370E】Rinne Loves Gift(Bellman_Ford判负环,二分,分数规划)
题干:链接:https://ac.nowcoder.com/acm/contest/370/E来源:牛客网 Rinne 喜欢礼物,也喜欢送礼物圣诞节快到了,Rinne 要去给给住在城市里的人送礼物城市的交通可以抽象成一个 n 个点 m 条边的有向图每条边上有 didi 个居民,Rinne 经过这条边的时候就会给她们每个人都送礼物由于 Rinne 的礼物并不是很多,她只在城市平均...原创 2019-02-18 20:00:30 · 289 阅读 · 0 评论 -
【牛客OI周赛7-普及组ABCD 非官方题解】暴力,二分,KMP,尺取(STL或Hash)
A:链接:https://ac.nowcoder.com/acm/contest/372/A来源:牛客网某天,一只可爱的肥橘喵在路上走,突然遇到了一个怪人,那怪人自称PM6,“小肥喵,这里有一道水题,答对了我就请你吃狗肉,答错了你就请我吃猫肉!”喵咪瑟瑟发抖:“QAQ什么题?”PM6道:“给你坐标轴上的N个点,求出对于每个点,有多少个点的 X 坐标和 Y 坐标都大于它。”...原创 2019-02-24 09:41:29 · 643 阅读 · 0 评论 -
【2019牛客暑期多校训练营(第六场)- D】Move(随机化二分)
题干:链接:https://ac.nowcoder.com/acm/contest/886/D来源:牛客网After the struggle of graduating from college, TangTang is about to move from a student apartment to his new home.TangTang has n items to m...原创 2019-08-22 14:41:46 · 325 阅读 · 0 评论 -
【CodeForces - 689D】Friends and Subsequences(RMQ,二分 或单调队列)
题干:Mike and !Mike are old childhood rivals, they are opposite in everything they do, except programming. Today they have a problem they cannot solve on their own, but together (with you)— who knows...原创 2019-08-24 22:22:48 · 307 阅读 · 0 评论 -
【HRBUST - 1996】数学等式 (HASH 或 二分)
题干:又到了数学题的时刻了,给出三个数组A,B,C,然后再给出一个数X,现在我想知道是否能找到三个数满足等式A[i]+B[j]+C[k]=X,你能帮助我么??Input本题有多组数据,每组数据第一行输入三个数n,m,h,分别表示数组A,B,C内的的元素个数(0<n,m,h<=500)接下来三行分别输入数组A,B,C的元素接下来输入一个数Q,表示Q次询问(1&l...原创 2019-07-11 22:07:04 · 392 阅读 · 0 评论 -
【牛客 - 551G】CSL的训练计划(二分 + 拓扑排序 + 优化卡常)
题干:链接:https://ac.nowcoder.com/acm/contest/551/G来源:牛客网题目描述众所周知,CSL 是一个负责的集训队队长。为了让集训队的学弟们训练更加饱和,他根据每个人的能力,提出了 m 个题数要求。假如 CSL 认为 yi比 xi 强,那么如果 xixi 做了 a 题,那 CSL 会要求 yi 需要做至少 a+ri×k,其中 riri 是已知的常...原创 2019-04-01 20:30:50 · 302 阅读 · 0 评论 -
【Gym - 101608G】WiFi Password (区间或,线段树 或 按位处理+尺取 或 二分)
题干:Just days before the JCPC, your internet service went down. You decided to continue your training at the ACM club at your university. Sadly, you discovered that they have changed the WiFi passwor...原创 2019-04-04 16:51:21 · 362 阅读 · 0 评论 -
【EOJ Monthly 2019.02 - A】回收卫星(交互题型,二分)
题干:单测试点时限: 1.0 秒内存限制: 256 MB“这个世上没有无用的齿轮,也只有齿轮本身能决定自己的用途。”就像太空中的卫星,虽然不计其数,但都各司其职。但没有一个东西是能够永远无损的。为了便于回收及修理,卫星在故障后会生成一个球形的星场,与之配对的感应器能判断其是否在星场内。QQ 小方现在要负责卫星的回收工作,他负责使用这些感应器锁定卫星的位置。QQ 小方有卫星基...原创 2019-02-26 14:46:34 · 414 阅读 · 0 评论 -
【EOJ Monthly 2019.02 - E】中位数(二分 ,中位数 ,−1/1变换,dp求解DAG最长路)
题干:E. 中位数单测试点时限: 10.0 秒内存限制: 256 MB“你的地图是一张白纸,所以即使想决定目的地,也不知道路在哪里。”QQ 小方最近在自学图论。他突然想出了一个有趣的问题:一张由 n 个点,m 条边构成的有向无环图。每个点有点权 Ai 。QQ 小方想知道所有起点为 1 ,终点为 n 的路径中最大的中位数是多少。一条路径的中位数指的是:一条路径有 n 个点...原创 2019-02-26 14:48:37 · 432 阅读 · 0 评论 -
【hihocoder - offer编程练习赛60 A】hohahola(贪心,二分)
题干:时间限制:10000ms单点时限:1000ms内存限制:256MB描述有一种叫作hohahola的饮料,售价是X元一瓶。小Hi非常喜欢这种饮料,但是他现在身无分文。不过小Hi有N张优惠券,买hohahola时每瓶最多使用一张优惠券,可以使该瓶价格减少Y元。(Y ≤ X) 同时优惠券可以出售,小Hi每出售一张优惠券可以获得Z元。 请你帮小Hi计算通过出售若干...原创 2019-02-13 20:34:39 · 310 阅读 · 0 评论 -
*【计蒜客 - 蓝桥训练】人以群分(二分 + dp)
题干:某班有nn个同学,每个同学有一个外向程度a_iai。由于要进行某个活动,需要把他们分成若干个小组,每个小组的人数至少为mm人。不同外向程度的人在一个小组会产生不开心值,定义一个小组的不开心值为组内成员外向程度最大值和最小值的差,一个班级的不开心值为所有小组不开心值的最大值。那么问题来了,如何分组使得班级的不开心值最小,请你求出这个最小的班级不开心值。输入格式第一行...原创 2019-02-13 20:28:33 · 1801 阅读 · 2 评论 -
【POJ - 2785】4 Values whose Sum is 0 (二分,折半枚举)
题干:The SUM problem can be formulated as follows: given four lists A, B, C, D of integer values, compute how many quadruplet (a, b, c, d ) ∈ A x B x C x D are such that a + b + c + d = 0 . In the fol...原创 2018-10-25 22:42:50 · 256 阅读 · 0 评论 -
【CodeForces - 760B 】Frodo and pillows (二分题意,注意细节)
题干:n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone w...原创 2018-10-25 22:11:19 · 572 阅读 · 0 评论 -
【CodeForces - 985D】Sand Fortress (二分,贪心,思维构造,技巧,有坑)
题干:You are going to the beach with the idea to build the greatest sand castle ever in your head! The beach is not as three-dimensional as you could have imagined, it can be decribed as a line of spo...原创 2018-10-20 22:53:39 · 682 阅读 · 0 评论 -
*【CodeForces - 799C】Fountains (线段树 或 树状数组,类似二元组问题)
题干:Arkady plays Gardenscapes a lot. Arkady wants to build two new fountains. There arenavailable fountains, for each fountain its beauty and cost are known. There are two types of money in the gam...原创 2018-09-09 01:14:45 · 591 阅读 · 2 评论 -
【CodeForces - 670D1 】Magic Powder - 1 (模拟 或 枚举 或二分优化)
题干:This problem is given in two versions that differ only by constraints. If you can solve this problem in large constraints, then you can just write a single solution to the both versions. If you f...原创 2018-09-05 00:49:15 · 343 阅读 · 0 评论 -
jsk Star War (线段树维护区间最小最大值 + 二分)
Description公元20XX年,人类与外星人之间的大战终于爆发。现有一个人类军团,由n名士兵组成,第i个士兵的战斗力值对应一个非负整数ai (1 \leq i \leq n1≤i≤n)。有一天,某个战力爆表的外星人NaN单独向地球人宣战,已知它的战力值为k (1 \leq k \leq 1e131≤k≤1e13)。现在该军团指挥官决定派遣编号在某个区间(l,r)内的士兵去与敌方决...原创 2018-10-27 00:54:33 · 242 阅读 · 0 评论 -
【CSU - 1023】【HRBUST - 1039】修路(二分,枚举)
题干:前段时间,某省发生干旱,B山区的居民缺乏生活用水,现在需要从A城市修一条通往B山区的路。假设有A城市通往B山区的路由m条连续的路段组成,现在将这m条路段承包给n个工程队(n ≤ m ≤ 300)。为了修路的便利,每个工程队只能分配到连续的若干条路段(当然也可能只分配到一条路段或未分配到路段)。假设每个工程队修路的效率一样,即每修长度为1的路段所需的时间为1。现在给出路段的数量m,工程队的...原创 2018-09-16 00:05:31 · 246 阅读 · 0 评论 -
【HDU - 2899】 Strange fuction(二分或三分,求导)
题干:Now, here is a fuction: F(x) = 6 * x^7+8*x^6+7*x^3+5*x^2-y*x (0 <= x <=100) Can you find the minimum value when x is between 0 and 100.InputThe first line of the input contains an i...原创 2018-07-26 15:50:49 · 286 阅读 · 0 评论 -
【CF#706B】 Interesting drink (二分)
题干: 瓦西里喜欢在努力工作后休息,所以你可能经常在附近的一些酒吧见到他。他喜欢 "Beecola",可以从 n 个不同的商店买到。在第 i 个商店的价格为 xi 元。瓦西里计划购买他最喜欢的饮料 q 次。在第 i 天他能花 mi 元。他想知道每天他能在多少个商店中买这些饮料。Input第一行包含一个整数 n (1 ≤ n ≤ 100 000) — 表示商店的数量。第二行包...原创 2018-07-27 16:41:36 · 387 阅读 · 0 评论 -
*【POJ - 3061】 Subsequence (尺取或二分)
题干:A sequence of N positive integers (10 < N < 100 000), each of them less than or equal 10000, and a positive integer S (S < 100 000 000) are given. Write a program to find the minimal len...原创 2018-07-26 00:50:11 · 227 阅读 · 0 评论 -
【HihoCoder - 1269】 优化延迟 (优先队列+二分优化)
题干:小Ho编写了一个处理数据包的程序。程序的输入是一个包含N个数据包的序列。每个数据包根据其重要程度不同,具有不同的"延迟惩罚值"。序列中的第i个数据包的"延迟惩罚值"是Pi。如果N个数据包按照<Pi1, Pi2, ... PiN>的顺序被处理,那么总延迟惩罚SP=1*Pi1+2*Pi2+3*Pi3+...+N*PiN(其中i1, i2, ... iN是1, 2, 3, .....原创 2018-07-26 00:39:21 · 253 阅读 · 0 评论 -
*【CF#633B】 A Trivial Problem(二分或枚举)
题干:Mr. Santa asks all the great programmers of the world to solve a trivial problem. He gives them an integer m and asks for the number of positive integers n, such that the factorial of n ends with...原创 2018-07-25 00:20:03 · 246 阅读 · 0 评论 -
**【POJ - 3122】 Pie(二分寻值)
题干:My birthday is coming up and traditionally I'm serving pie. Not just one pie, no, I have a number N of them, of various tastes and of various sizes. F of my friends are coming to my party and eac...原创 2020-12-20 12:31:04 · 315 阅读 · 0 评论 -
【CF#192 A】Funky Numbers (二分,查找,二元组)
题干:As you very well know, this year's funkiest numbers are so called triangular numbers (that is, integers that are representable as , where k is some positive integer), and the coolest numbers are ...原创 2018-09-13 11:45:30 · 291 阅读 · 0 评论 -
【CodeForces - 803D】Magazine Ad(二分答案)
题干:The main city magazine offers its readers an opportunity to publish their ads. The format of the ad should be like this:There are space-separated non-empty words of lowercase and uppercase Lati...原创 2018-09-15 23:56:23 · 377 阅读 · 0 评论 -
【POJ - 2318】TOYS(计算几何,叉积判断点与直线位置关系,二分)
题干:Calculate the number of toys that land in each bin of a partitioned toy box. Mom and dad have a problem - their child John never puts his toys away when he is finished playing with them. They ga...原创 2018-09-06 16:56:49 · 348 阅读 · 0 评论 -
【51Nod - 1094】和为k的连续区间 (前缀和,二分查找)
题干:一整数数列a1, a2, ... , an(有正有负),以及另一个整数k,求一个区间i,ji,j,(1 <= i <= j <= n),使得aii + ... + ajj = k。Input第1行:2个数N,K。N为数列的长度。K为需要求的和。(2 <= N <= 10000,-10^9 <= K <= 10^9)第2 - N + 1行...原创 2018-10-27 00:54:55 · 480 阅读 · 0 评论 -
【PAT - 甲级 - 1018】Public Bike Management (带权最短路,多条最短路中加条件,DFS)
题干:链接:https://www.nowcoder.com/questionTerminal/4b20ed271e864f06ab77a984e71c090f来源:牛客网There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over...原创 2018-10-10 16:04:19 · 465 阅读 · 0 评论