Codeforces 467C George and Job(DP)】的更多相关文章

题目 Source http://codeforces.com/contest/467/problem/C Description The new ITone 6 has been released recently and George got really keen to buy it. Unfortunately, he didn't have enough money, so George was going to work as a programmer. Now he faced t…
题意:构造一个由a组成的串,如果插入或删除一个a,花费时间x,如果使当前串长度加倍,花费时间y,问要构造一个长度为n的串,最少花费多长时间. 分析:dp[i]---构造长度为i的串需要花费的最短时间. 1.构造长度为1的串,只能插入,dp[1] = x. 2.当前串的长度i为偶数,可以 (1)长度为i/2的串加倍:dp[i / 2] + y (2)长度为i-1的串插入一个a:dp[i - 1] + x 3.当前串的长度i为奇数,可以 (1)长度为i/2的串加倍,再加上一个a:dp[i / 2]…
题目 参考了网页:http://www.xue163.com/exploit/180/1802901.html //看了题解,抄了一遍,眼熟一下,增加一点熟练度 //dp[i][j]表示是前i个数选出j段的最大值, //显然有不选这个数,和考虑这个数的两种情况. //而考虑这个数的话,因为连续性也只会增加以这个数为结尾的m序列 #include<stdio.h> #include<string.h> #include<algorithm> using namespace…
wa哭了,,t哭了,,还是看了题解... 8170436                 2014-10-11 06:41:51     njczy2010     C - George and Job             GNU C++     Accepted 109 ms 196172 KB 8170430                 2014-10-11 06:39:47     njczy2010     C - George and Job             GNU C…
Codeforces Round #267 (Div. 2) C. George and Job题目链接请点击~ The new ITone 6 has been released recently and George got really keen to buy it. Unfortunately, he didn't have enough money, so George was going to work as a programmer. Now he faced the follow…
职务地址:http://codeforces.com/contest/467/problem/C 太弱了..这题当时都没做出来..思路是有的,可是自己出的几组数组总是过不去..今天又又一次写了一遍.才发现当时一个地方脑残了..每次选的最大值应该是与更新后的位置的前一个比而不是当前所在的位置. 二维DP. 代码例如以下: #include <iostream> #include <cstdio> #include <string> #include <cstring…
题目 传送门:QWQ 分析 dp基础题. $ dp[i][j] $表示前i个数分成j组的最大和. 转移显然. 吐槽:做cf题全靠洛谷翻译苟活. 代码 #include <bits/stdc++.h> using namespace std; typedef long long ll; ; ll dp[maxn][maxn], sum[maxn], a[maxn]; ll Sum(];} int main(){ int n,m,k; scanf("%d%d%d",&n…
https://codeforces.com/contest/1051/problem/D 题意 一个2*n的矩阵,你可以用黑白格子去填充他,求联通块数目等于k的方案数,答案%998244353. 思路 按列dp,定义状态dp[i][j][k]为前i列,有j个联通块,最后一列为k的方案数 处理出列状态之间的转移(会新产生多少个新的联通块) 注意初始化问题 #include<bits/stdc++.h> #define P 998244353 #define ll long long using…
Codeforces 题目传送门 & 洛谷题目传送门 其实这题本该 2019 年 12 月就 AC 的(详情请见 ycx 发此题题解的时间),然鹅鸽到了现在-- 首先以 \(s,t\) 分别为源点跑两遍 dijkstra 是不可避免的,求出 \(s,t\) 到每个点的最短距离 \(d1_i,d2_i\) 其次还可以发现一件事情,那就是对于 \(\forall i,j\),若 \(d1_i<d1_j\) 并且 \(j\) 被选择了,那么 \(i\) 一定被选择了,对于 \(d2_i\) 也可得…
Codeforces Round #267 (Div. 2) C. George and Job time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The new ITone 6 has been released recently and George got really keen to buy it. Unfortunate…