
动态规划
为啥不能重名
这个作者很懒,什么都没留下…
展开
-
L3-020 至多删三个字符 (30 分)(dp)
#include <bits/stdc++.h>#define N 1000100using namespace std;long long int dp[N][4],sum;int main(){ char s[N]; scanf("%s",s+1); int m=strlen(s+1); dp[0][0]=1; for(int i=1; i<=m; i++) { for(int j=0; j<=3; j+.原创 2021-04-08 19:51:08 · 131 阅读 · 0 评论 -
274. 移动服务
一个公司有三个移动服务员,最初分别在位置1,2,3处。如果某个位置(用一个整数表示)有一个请求,那么公司必须指派某名员工赶到那个地方去。某一时刻只有一个员工能移动,且不允许在同样的位置出现两个员工。从 p 到 q 移动一个员工,需要花费 c(p,q)。这个函数不一定对称,但保证 c(p,p)=0。给出N个请求,请求发生的位置分别为 p1~pN。公司必须按顺序依次满足所有请求,且过程中不能去其他额外的位置,目标是最小化公司花费,请你帮忙计算这个最小花费。输入格式第1行有两个整数L,N,其中L是原创 2021-01-29 17:37:33 · 101 阅读 · 0 评论 -
动态规划求最长降序序列
这里可以用到两个stl库中的两个函数,lower_bound() 和 upper_bound().lower_bound(a+1,a+n+1,x)是求一个序列中第一个大于等于x的数的位置。upper_bound(a+1,a+n+1,x)是求一个序列中第一个大于x的数的位置。这里的序列必须是有序序列,所谓有序系列,在STL库中默认有序序列为升序序列,而且一旦对降序序列做upper_bound(),就会发生错误。那么如果我们想要得到一个有序序列中第一个小于或者小于等于x的数的位置,又该怎么办那?我们可原创 2020-11-23 21:46:05 · 319 阅读 · 0 评论 -
G - Gig Combinatorics Kattis - gigcombinatorics
题目来源:https://vjudge.net/contest/409021#problem/G思路:dp动态规划,本题的题意是取一个数列的子数列–第一个数是1,最后一个数是3,中间的数是2,问有多少种情况。记忆化处理前面有多少个1 、2 、3,但是2要特别注意,因为2可以是多个,2前面的2,可以选也可以不选,这两种情况都要算进去。ac代码:#include <iostream>#include <bits/stdc++.h>using namespace std;#de原创 2020-11-23 20:39:58 · 301 阅读 · 0 评论 -
动态规划Problem C. String Game
Clair and Bob play a game. Clair writes a string of lowercase characters, in which Bob sets the puzzleby selecting one of his favorite subsequence as the key word of the game. But Bob was so stupid that hemight get some letters wrong.Now Clair wants to原创 2020-11-19 20:23:46 · 485 阅读 · 0 评论