摘要: 一.能量项链 https://www.luogu.org/problem/P1063 (这道题和紫书里的最优矩阵链乘很像) ①分析样例: 4 2 3 5 10 我们把它写成4个乘法表达式: 2*3 3*5 5*10 10*2 合并它需要3次乘法: 10*2*3 3*5 5*10 能量+60 10*2 阅读全文
posted @ 2019-11-12 20:48 Neptune0 阅读(107) 评论(0) 推荐(0) 编辑
摘要: 读完题目我们大概就可以想到一种暴力解法了 #include<iostream> #include<cstring> #include<cstdio> using namespace std; const int N=1e6+5; int sum[N],d,r[N],s,t,n,m; int main 阅读全文
posted @ 2019-11-12 18:52 Neptune0 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 题干中说”最短距离尽可能长”,那么我们想到二分答案。 那么这道题的答案有没有一个可行的范围呢,该区间是否符合单调性呢? 来看范围: 显然对于初始的数据,从0到n+1的相邻石头的距离,我们可以找到一个初始的dismin,这个可以作为left, 显然right=length(移除所有石头)。 来看单调性 阅读全文
posted @ 2019-11-12 09:50 Neptune0 阅读(126) 评论(0) 推荐(0) 编辑