随笔分类 -  二分

1 2 下一页

小小粉丝度度熊 二分答案 + two pointer
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=6119 发现自己的two pointer能力超弱。 这题是合并时间后,二分答案。 可以知道对于每个时间区间,合法的答案肯定是从其开始时间,向左扩展 或者从其结束时间,向右扩展。 复杂度O(2n log val) 细 阅读全文

posted @ 2017-08-14 21:53 stupid_one 阅读(286) 评论(0) 推荐(0) 编辑

I - Defeat the Enemy UVALive - 7146 二分 + 贪心
摘要:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=5158 这样的受到两个东西限制的,很容易想到要排序,然后加进去multiset,加的时候保证 阅读全文

posted @ 2017-08-11 13:56 stupid_one 阅读(277) 评论(0) 推荐(0) 编辑

Sorted Subsegments
摘要:https://www.hackerrank.com/contests/101hack38/challenges/sorted-subsegments/problem 首先要注意到可以二分答案,比如当前位置是4,二分答案是2,是可以的,往大的找找就好。 然后把 >= 2的变成1, < 2的变成0,然 阅读全文

posted @ 2017-07-25 00:03 stupid_one 阅读(374) 评论(0) 推荐(0) 编辑

C. Glass Carving 正着做或者倒着做都可以
摘要:http://codeforces.com/problemset/problem/527/C 这题总体思路就是,每画一条线,然后就找到x间距的最max值和y间距的最max值,相乘就是当前的ans 那么我需要维护这样的一个数列,每次往里面添加一个元素,然后查询相邻两个元素的差值的最大值。 倒着做比较简 阅读全文

posted @ 2017-07-22 21:45 stupid_one 阅读(246) 评论(0) 推荐(1) 编辑

F. Bakkar In The Army 二分
摘要:http://codeforces.com/gym/100283/problem/F 思路是二分第几行,二分出来的行是总和 >= n的,那么第k - 1行一定要选,那么再在第k行中二分那一列、 #include <cstdio> #include <cstdlib> #include <cstrin 阅读全文

posted @ 2017-04-17 12:18 stupid_one 阅读(185) 评论(0) 推荐(0) 编辑

Codeforces Round #202 (Div. 1) A. Mafia 推公式 + 二分答案
摘要:http://codeforces.com/problemset/problem/348/A A. Mafia time limit per test 2 seconds memory limit per test 256 megabytes input standard input output 阅读全文

posted @ 2017-04-14 21:00 stupid_one 阅读(262) 评论(0) 推荐(0) 编辑

D. Dasha and Very Difficult Problem 二分
摘要:http://codeforces.com/contest/761/problem/D c[i] = b[i] - a[i],而且b[]和a[]都属于[L, R] 现在给出a[i]原数组和c[i]的相对大小,要确定b[i] 因为已经知道了c[i]的相对大小,那么从最小的那个开始,那个肯定是选了L的了 阅读全文

posted @ 2017-02-01 01:52 stupid_one 阅读(181) 评论(0) 推荐(0) 编辑

1268 和为K的组合 Meet in mid二分思路
摘要:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1268&judgeId=193772 给出n = 20个数,问其是否有和为k的情况 分两段,用O(2^(n / 2))复杂度维护出每一段的所有情况。 然后枚举第一段,二分判断 阅读全文

posted @ 2017-01-31 02:08 stupid_one 阅读(167) 评论(0) 推荐(0) 编辑

C. Two strings 二分 + 预处理
摘要:http://codeforces.com/contest/762/problem/C 第一个串str[],第二个sub[] 预处理出prefix[i]表示sub的前i位和str[]的最长lcs去到str[]的最小的位置,如果某一位i不成立了,就设为inf 由于处理的时候,指针指向str[]的是单调 阅读全文

posted @ 2017-01-26 23:22 stupid_one 阅读(140) 评论(0) 推荐(0) 编辑

1065 最小正子段和 二分答案 + 判定
摘要:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1065 我的思路比较笨,我是直接二分那个答案mid 然后进行一次O(nlogn)的判定,如果能找到一个区间的和比mid小的,(当然这个区间的和也是要大于0),那就return 阅读全文

posted @ 2017-01-26 22:58 stupid_one 阅读(156) 评论(0) 推荐(0) 编辑

E. Santa Claus and Tangerines 二分答案 + 记忆化搜索
摘要:http://codeforces.com/contest/752/problem/E 首先有一个东西就是,如果我要检测5,那么14我们认为它能产生2个5. 14 = 7 + 7.但是按照平均分的话,它是不能产生5的,那就把那两个7当成是两个5,因为7比5还大,对min(b[i])是没有影响的。 可 阅读全文

posted @ 2016-12-25 23:57 stupid_one 阅读(186) 评论(0) 推荐(0) 编辑

D. Leaving Auction 一题很好的思维题
摘要:http://codeforces.com/contest/749/problem/D 现在发现做题要把样例抄下来,然后画一画,这样才容易发现新大陆。嗯,以后做题就这样。 如果排除了被删除了的人,那么,剩下的人中,胜出的,就是剩下出价最高的那个,但是它有可能不需要出价那么高,所以只需要比现在剩下的人 阅读全文

posted @ 2016-12-21 23:22 stupid_one 阅读(196) 评论(0) 推荐(0) 编辑

D. Alyona and a tree 公式转换 + 分块暴力
摘要:http://codeforces.com/problemset/problem/740/D 对于每一对<u, v>。设dis[u]表示root到点u的距离,那么dis<u去v>就是dis[v] - dis[u], 就是在它的儿子中找出有多少个v使得dis[v] - dis[u] <= a[v]。然 阅读全文

posted @ 2016-12-12 21:59 stupid_one 阅读(263) 评论(0) 推荐(0) 编辑

D. Black Hills golden jewels 二分答案 + 二分判定
摘要:http://codeforces.com/gym/101064/problem/D 题目是给定一个数组,如果两两组合,有C(n, 2)种结果,(找出第一个大于等于第k大的结果) 思路, 二分答案val,判断如下。 先把数组排序。 然后暴力枚举每个数a[i],那么找出第一个大于val - a[i]的 阅读全文

posted @ 2016-12-07 01:06 stupid_one 阅读(332) 评论(0) 推荐(0) 编辑

C. Anton and Making Potions 贪心 + 二分
摘要:http://codeforces.com/contest/734/problem/C 因为有两种操作,那么可以这样考虑, 1、都不执行,就是开始的答案是n * x 2、先执行第一个操作,然后就会得到一个time和left。就是你会得到一个新的用时,和一个剩下的魔法数,然后在第二个操作数中二分,二分 阅读全文

posted @ 2016-11-16 09:53 stupid_one 阅读(183) 评论(0) 推荐(0) 编辑

17997 Simple Counting 数学
摘要:17997 Simple Counting 时间限制:2000MS 内存限制:65535K提交次数:0 通过次数:0 题型: 编程题 语言: 不限定 Description 输入格式 The first line of the input is an integer T , indicates th 阅读全文

posted @ 2016-11-13 22:34 stupid_one 阅读(337) 评论(0) 推荐(0) 编辑

G. Of Zorcs and Axes 二分 + 贪心 —— STL的用法
摘要:http://codeforces.com/gym/101149/problem/G 一开始还以为要用二分图去做,但是复杂度也太高了,O(n * m)的话直接爆炸。 考虑贪心,考虑第i个东西优先选一个能选的,而且这个东西的值尽量小。 就是如果要<3, 3>的话,我希望找到有序对<x, y>,其中x和 阅读全文

posted @ 2016-11-08 22:31 stupid_one 阅读(258) 评论(0) 推荐(0) 编辑

Codeforces Round #377 (Div. 2) E. Sockets
摘要:http://codeforces.com/contest/732/problem/E 题目说得很清楚,每个电脑去插一个插座,然后要刚好的,电脑的power和sockets的值相同才行。 如果不同,还有一个操作,就是在sockets中插东西,使得sockets的值变成val / 2 + (val & 阅读全文

posted @ 2016-10-22 20:34 stupid_one 阅读(210) 评论(0) 推荐(0) 编辑

URAL 1948 H - The Robot on the Line 二分 + 数学
摘要:http://acm.hust.edu.cn/vjudge/contest/126149#problem/H 给定一条二次函数 f (x) = a * x * x + b * x + c 求一个最小的k,使得f(x) + f(x + 1) + f(x + 2) ..... + f(x + k - 1 阅读全文

posted @ 2016-09-05 08:51 stupid_one 阅读(222) 评论(0) 推荐(0) 编辑

HDU - 4366 Successor DFS序 + 分块暴力 or 线段树维护
摘要:给定一颗树,每个节点都有忠诚和能力两个参数,随意指定一个节点,要求在它的子树中找一个节点代替它,这个节点要满足能力值大于它,而且是忠诚度最高的那个。 首先,dfs一下,处理出L[i], R[i]表示dfs序,则R[i] - L[i] + 1 就是当前i这个节点拥有的子孙个数。 对于一颗树,dfs的时 阅读全文

posted @ 2016-08-31 23:35 stupid_one 阅读(243) 评论(0) 推荐(0) 编辑

1 2 下一页
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示