SCU3037 Painting the Balls】的更多相关文章

Description Petya puts the \(N\) white balls in a line and now he wants to paint some of them in black, so that at least two black balls could be found among any \(M\) successive balls. Petya knows that he needs \(C_i\) milliliters of dye exactly to…
dp..dp(i, j)表示画两个点为i-j, i的最优答案. dp(i, j) = min{ dp(i-j, k) } + cost[i] (1≤k≤M-j) 令f(i, j) = min{dp(i, j)}, 那么转移时间下降为O(1).然后滚动数组..这道题卡空间..时间复杂度O(NM) -------------------------------------------------------------------------------- #include<cstdio> #in…
183. Painting the balls time limit per test: 0.25 sec.memory limit per test: 4096 KB input: standard inputoutput: standard output Petya puts the N white balls in a line and now he wants to paint some of them in black, so that at least two black balls…
题意:给n个白球,选其中一些涂为黑色,且给了涂第i个球的花费为ci,要求每m个连续的球中至少有两个黑球,问最小花费是多少? 容易想到一个方程dp[i][j]=min{dp[k][i]}+c[j] dp[i][j]表示最后上色的两个球分别是第i和第j个球(i<j)时的最优解. 我们从条件每m个连续的球中至少有两个黑球可以得出k的范围j-m<=k<i 如果我们直接按上面这个方程去做的话时间复杂度是O(n*m*m). #include <iostream> #include <…
时间限制:0.25s 空间限制:4M 题意:  在n(n<=10000)个球中,给若干个球涂色,每个球涂色的代价为Ci,使得任意连续m(m<=100)个球中有至少两个球被涂了色. Solution: 首先很直接地能想到一个DP的状态转移方程 f[i][j] 代表,当前涂第i个球,且前面最近一个被涂色的球为j的最小代价 f[i][j]=min(f[j][k])+Ci,   k>i+1-m 分析这个转移方程的时间复杂度是O(n*m*m)在此题的数据范围中高达10^8 显然我们需要更好的解法…
-----------------------------最优化问题------------------------------------- ----------------------常规动态规划  SOJ1162 I-Keyboard  SOJ1685 Chopsticks SOJ1679 Gangsters SOJ2096 Maximum Submatrix  SOJ2111 littleken bg SOJ2142 Cow Exhibition  SOJ2505 The County…
http://acm.sgu.ru/problemset.php?contest=0&volume=1 101 Domino 欧拉路 102 Coprime 枚举/数学方法 103 Traffic Lights 最短路 104 Little Shop of Flowers 动态规划 105 Div 3 找规律 106 The Equation 扩展欧几里德 107 987654321 Problem 找规律 108 Self-numbers II 枚举+筛法递推 109 Magic of Dav…
Ball Painting 题目连接: http://codeforces.com/gym/100015/attachments Description There are 2N white balls on a table in two rows, making a nice 2-by-N rectangle. Jon has a big paint bucket full of black paint. (Don't ask why.) He wants to paint all the b…
C. Kyoya and Colored Balls Time Limit: 2000ms Memory Limit: 262144KB 64-bit integer IO format: %I64d      Java class name: (Any) Submit Status Kyoya Ootori has a bag with n colored balls that are colored with k different colors. The colors are labele…
今天讨论的是称球问题. No.3 13 balls problem You are given 13 balls. The odd ball may be either heavier or lighter. Find out the odd ball in 3 weightings. 分析与解答: 看到这道题,就想起来高中时候数学老师的一句话:“真正难的题不是那些很长的题,而是那些就几句话的题!!!”现在想想真是良训啊.又想到很多老师的话,感觉到失去方显弥足珍贵的名言,不禁唏嘘啊…… 有人认为…