随笔分类 -  递推

摘要:problem初始序列全为0,每次操作可以将一个区间全部加1。 求最少操作数使序列变为目标序列。solution我们设d[i]=a[i]-a[i-1], 显然如果我将l~r进行操作相当于将d[l]加一而将d[r+1]减一(差分)所以最少操作数就是所有正权d值的和。(把... 阅读全文
posted @ 2018-07-27 20:41 gwj1139177410 阅读(150) 评论(0) 推荐(0)
摘要:problemsolutioncodes#includeusing namespace std;int n, ans = 0, t;void f(int a, char b, char c){ ans++; if(a == 1){ if(t)... 阅读全文
posted @ 2018-06-05 21:14 gwj1139177410 阅读(151) 评论(0) 推荐(0)
摘要:problemsolutioncodes#includeusing namespace std;const int maxn = 1010;int f[maxn];int main(){ int n; cin>>n; for(int i = 1; i <... 阅读全文
posted @ 2018-06-01 21:16 gwj1139177410 阅读(147) 评论(0) 推荐(0)
摘要:problemsolutioncodes#includeusing namespace std;const int maxn = 11;int f[maxn][maxn];int main(){ for(int i = 0; i i?f[i][i]:f[i][j... 阅读全文
posted @ 2018-05-26 13:19 gwj1139177410 阅读(106) 评论(0) 推荐(0)

选择