CF 455A(Boredom-dp)】的更多相关文章

A. Boredom time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a ga…
题目链接:https://codeforces.com/problemset/problem/455/A 题意: 给出一个 $n$ 个数字的整数序列 $a[1 \sim n]$,每次你可以选择一个 $a[k]$ 将其删除,同时还会删除序列中所有等于 $a[k] + 1$ 和 $a[k] - 1$ 的元素. 每做这样一次操作,你可以获得 $a[k]$ 的分数,求可以得到的最大分数. 题解: 首先,看到 $a[1 \sim n]$ 的取值最大不超过 $1e5$,就应当想到在这个上面做文章. $f[x…
http://codeforces.com/problemset/problem/553/A A. Kyoya and Colored Balls time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Kyoya Ootori has a bag with n colored balls that are colored with …
Boredom 题目链接: http://acm.hust.edu.cn/vjudge/contest/121334#problem/G Description Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it. Given a sequ…
<题目链接> 题目大意:给定一个序列,让你在其中挑选一些数,如果你选了x,那么你能够得到x分,但是该序列中所有等于x-1和x+1的元素将全部消失,问你最多能够得多少分. 解题分析:从小到大枚举选的数的数值,同时用DP进行状态的转移,$dp[i]$表示前 $i$ 的数值中,挑选$i$的最大得分. 所以不难得到dp的转移方程为:$$dp[i]=max(dp[i-1],dp[i-2]+num[i]*i)$$ #include <bits/stdc++.h> using namespace…
题目链接:点击打开链接 给定一个n长的序列 删除x这个数就能获得x * x的个数 的分数,然后x+1和x-1这2个数会消失.即无法获得这2个数的分数 问最高得分. 先统计每一个数出现的次数.然后dp一下,对于每一个数仅仅有取或不取2种状态. #include <algorithm> #include <cctype> #include <cassert> #include <cstdio> #include <cstring> #include…
今天早上找一道题的bug,还是找不出来,下午刷了几道水题,晚上准备回家的事, 然后本来想打CF的,一看,数学场,不打了. 这道题的题意: 给出一个序列,每次你可以从这个序列里面选择一个数ak,删除,然后你的得分+ak, 代价是序列里面值为ak+1,ak-1的元素都删除 问:你能得到的最大得分是多少 思路: 你若删除了一个值为a的数,你的得分就是a*序列里面a的个数 因为a+1和a-1都被删除了,则其余的a不会被a+1,a-1这种情况删除了,你一定可以得到所有a的分数 所以这道题就是:在序列里面选…
A. Boredom Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/455/problem/A Description Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and d…
先说HDU 4632这道题,因为比较简单,题意就是给你一个字符串,然后给你一个区间,叫你输出区间内所有的回文子序列,注意是回文子序列,不是回文字串. 用dp[i][j]表示区间[i,j]内的回文子序列的个数. 那么可以得到状态转移方程:dp[i][j] = dp[i + 1][j] + dp[i][j - 1] - dp[i + 1][j - 1] + a[i] == a[j] . #define N 1005 #define MOD 10007 int dp[N][N] ; char a[N]…
CF 219D [题目链接]CF 219D [题目类型]树形DP &题意: 给一个n节点的有向无环图,要找一个这样的点:该点到其它n-1要逆转的道路最少,(边<u,v>,如果v要到u去,则要逆转该边方向)如果有多个这样的点,则升序输出所有. &题解: 参考自:http://blog.csdn.net/angon823/article/details/52316220 需要求每个点到其他n-1个点是否要逆转路径,那么就可以把正的路cost=1,逆转的cost=0,这只要求这个点到…