Live2d Test Env

随笔分类 -  DP----优化

摘要:Collecting one's own plants for use as herbal medicines is perhaps one of the most self-empowering things a person can do, as it implies that they hav 阅读全文
posted @ 2018-11-05 10:54 nimphy 阅读(375) 评论(0) 推荐(0)
摘要:现在给你一个长度为n的整数序列,其中有一些数已经模糊不清了,现在请你任意确定这些整数的值, 使得最长上升子序列最长。(为何最长呢?因为hxy向来对自己的rp很有信心) Input 第一行一个正整数n 接下来n行第i行格式如下 K x:表示第i个数可以辨认且这个数为x N:表示第i个数一个已经辨认不清 阅读全文
posted @ 2018-10-31 15:52 nimphy 阅读(386) 评论(0) 推荐(0)
摘要:有M个球,一开始每个球均有一个初始标号,标号范围为1~N且为整数,标号为i的球有ai个,并保证Σai = M。 每次操作等概率取出一个球(即取出每个球的概率均为1/M),若这个球标号为k(k < N),则将它重新标号为k + 1;若这个球标号为N,则将其重标号为1。(取出球后并不将其丢弃) 现在你需 阅读全文
posted @ 2018-09-18 19:47 nimphy 阅读(400) 评论(0) 推荐(0)
摘要:On Saint Valentine's Day, Alex imagined to present a special pendant to his girl friend made by K kind of pearls. The pendant is actually a string of 阅读全文
posted @ 2018-09-18 19:26 nimphy 阅读(257) 评论(0) 推荐(0)
摘要:Perhaps the sea‘s definition of a shell is the pearl. However, in my view, a shell necklace with n beautiful shells contains the most sincere feeling 阅读全文
posted @ 2018-09-17 15:58 nimphy 阅读(211) 评论(0) 推荐(0)
摘要:题意:一个环状数组,给定可以删去一个数,代价的相邻两个数的gcd,求最小代价。 思路:区间DP即可,dp[i][j]表示[i,j]区间只剩下i和j时的最小代价,那么dp[i][j]=min dp[i][k]+dp[k][j]+gcd(a[[i],a[j])。带上注意不能加倍做,以为常数会乘8,TLE 阅读全文
posted @ 2018-08-04 20:59 nimphy 阅读(510) 评论(0) 推荐(0)
摘要:注意初始化。。。等等补 阅读全文
posted @ 2018-07-18 12:48 nimphy 阅读(331) 评论(0) 推荐(0)
摘要:Limak is an old brown bear. He often goes bowling with his friends. Today he feels really good and tries to beat his own record! For rolling a ball on 阅读全文
posted @ 2018-06-30 11:42 nimphy 阅读(492) 评论(0) 推荐(0)
摘要:Zxr960115 is owner of a large farm. He feeds m cute cats and employs p feeders. There's a straight road across the farm and n hills along the road, nu 阅读全文
posted @ 2018-06-30 09:58 nimphy 阅读(623) 评论(0) 推荐(0)
摘要:机器上有N个需要处理的任务,它们构成了一个序列。这些任务被标号为1到N,因此序列的排列为1,2,3...N。这N个任务被分成若干批,每批包含相邻的若干任务。从时刻0开始,这些任务被分批加工,第i个任务单独完成所需的时间是Ti。在每批任务开始前,机器需要启动时间S,而完成这批任务所需的时间是各个任务需 阅读全文
posted @ 2018-06-29 17:57 nimphy 阅读(518) 评论(0) 推荐(0)
摘要:For the given sequence with n different elements find the number of increasing subsequences with k + 1 elements. It is guaranteed that the answer is n 阅读全文
posted @ 2018-05-31 20:15 nimphy 阅读(307) 评论(0) 推荐(0)
摘要:You are given a directed graph with n nodes and m edges, with all edges having a certain weight. There might be multiple edges and self loops, and the 阅读全文
posted @ 2018-05-31 18:32 nimphy 阅读(421) 评论(0) 推荐(0)
摘要:描述 某个夜晚,Bob将他弹奏的钢琴曲录下来发给Jack,Jack感动之余决定用吉他为他伴奏。 我们可以用一个整数表示一个音符的音高,并可认为Bob弹奏的曲子是由3N个整数构成的一个序列。其中每个整数的取值范围是[-200, 200]。 Jack共弹奏 N 个和弦,每个和弦由三个音符组成。Jack可 阅读全文
posted @ 2018-02-21 20:00 nimphy 阅读(500) 评论(0) 推荐(0)
摘要:大概是需要前缀和优化DP,和记录左右范围。 还有一道题,没有下手,等做完了,再来总结。 1,数组分拆: 给定数组,问有多少种拆分法,使得每一段和不为0。 (1e5) (用map优化DP) #include<map> #include<cstdio> #include<cstdlib> #includ 阅读全文
posted @ 2018-02-18 18:07 nimphy 阅读(318) 评论(0) 推荐(0)
摘要:描述 程序员常常需要给变量命名、给函数命名、给项目命名、给团队命名…… 好的名字可以大大提高程序员的主观能动性,所以很多程序员在起名时都会陷入纠结和烦恼。 小Hi希望给新的项目起个拉风的名字。他希望这个名字可以包含N个关键字,并且总长度最短。例如包含关键字abcd、cdab和dabc的最短字符串是c 阅读全文
posted @ 2018-02-17 23:18 nimphy 阅读(208) 评论(2) 推荐(0)
摘要:描述 小Ho面前有N个小球排成了一排。每个小球可以被染成M种颜色之一。 为了增强视觉效果,小Ho希望不存在连续K个或者K个以上的小球颜色一样。 你能帮小Ho计算出一共有多少种不同的染色方法么? 例如N=4, M=2, K=3,则有10种染色方法: 0010 0011 0100 0101 0110 1 阅读全文
posted @ 2017-12-27 17:19 nimphy 阅读(480) 评论(0) 推荐(0)
摘要:There is a straight highway with villages alongside the highway. The highway is represented as an integer axis, and the position of each village is id 阅读全文
posted @ 2017-11-11 17:53 nimphy 阅读(198) 评论(0) 推荐(1)
摘要:有很多种算法: 1,任意两堆可以合并:贪心+单调队列。 2,相邻两堆可合并:区间DP (O(n^3)) )。 3,相邻,四边形不等式优化DP (O(n^2) )。 4,相邻,GarsiaWachs算法 (O(nlgn))。 这里实现了第2,3种解法:(个人的区间DP习惯从后面向前面扫) 看起来第四种 阅读全文
posted @ 2017-11-11 15:31 nimphy 阅读(255) 评论(0) 推荐(0)
摘要:转自PomeCat: “DP的斜率优化——对不必要的状态量进行抛弃,对不优的状态量进行搁置,使得在常数时间内找到最优解成为可能。斜率优化依靠的是数形结合的思想,通过将每个阶段和状态的答案反映在坐标系上寻找解答的单调性,来在一个单调的答案(下标)队列中O(1)得到最优解。” https://wenku 阅读全文
posted @ 2017-11-11 09:31 nimphy 阅读(551) 评论(0) 推荐(0)
摘要:Zero has an old printer that doesn't work well sometimes. As it is antique, he still like to use it to print articles. But it is too old to work for a 阅读全文
posted @ 2017-11-10 15:29 nimphy 阅读(274) 评论(0) 推荐(0)