poj3671Dining Cows(DP)】的更多相关文章

主题链接: 啊哈哈,点我点我 题意: 给一个仅仅含有1.2的序列,如何变换n次使序列成为一个非递减的序列,而且使n最小. 思路: 这道题的数据范围是50000,则肯定承受不了n方的复杂度.所以 仅仅能写O(n)的算法,甚至更小,所以当时想二分,可是不知道怎么写,忽然想到能够枚举每个位置,把每个位置都当做一个分界点.然后求前半部有多少个2.后半段有多少个1,最后和所有是1和2进行比較,这个问题便得到了解决. 题目: Dining Cows Time Limit: 1000MS   Memory L…
dp( L , R ) = max( dp( L + 1 , R ) + V_L * ( n - R + L ) , dp( L , R - 1 ) + V_R * ( n - R + L ) ) 边界 : dp( i , i ) = V[ i ] * n -------------------------------------------------------------------------------------------- #include<cstdio> #include&l…
Description FJ has purchased N (1 <= N <= 2000) yummy treats for the cows who get money for giving vast amounts of milk. FJ sells one treat per day and wants to maximize the money he receives over a given period time. The treats are interesting for…
题目链接:http://poj.org/problem?id=3186 Treats for the Cows Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6548   Accepted: 3446 Description FJ has purchased N (1 <= N <= 2000) yummy treats for the cows who get money for giving vast amount…
/* 一开始并没有想出On的正解 后来发现题解的思路也是十分的巧妙的 还是没能把握住题目的 只有1 2这两个数的条件 dp还带练练啊 ... */ #include<iostream> #include<cstdio> #include<cstring> #define maxn 100010 using namespace std; int n,a[maxn],Q[maxn],H[maxn],ans=0x7fffffff; int main() { scanf(&qu…
题意:给定 n 个数,让你修改最少的数,使得这是一个不下降序列. 析:和3670一思路,就是一个LIS,也可以直接暴力,因为只有两个数,所以可以枚举在哪分界,左边是1,右边是2,更新答案. 代码如下: #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #include <cstring> #includ…
最近刷银组刷得好欢快,好像都是水题,在这里吧他们都记录一下吧(都是水题大家一定是道道都虐的把= =)几道比较神奇的题到时再列出来单独讲一下吧= =(其实我会说是BZOJ蹦了无聊再来写的么 = =) [Usaco2004 Dec]Bad Cowtractors牛的报复  很明显是最大生成树了吧,跟最小生成树一样做就行了 = =(排序时按从大到小的顺序排) [Usaco2004 Dec]Cleaning Shifts安排值班  贪心,按开始时间从小到大排,然后对于已经安排的时间,取在此时间开始的最晚…
Picnic Cows Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2192    Accepted Submission(s): 675 Problem Description It’s summer vocation now. After tedious milking, cows are tired and wish to t…
Description FJ has purchased N (1 <= N <= 2000) yummy treats for the cows who get money for giving vast amounts of milk. FJ sells one treat per day and wants to maximize the money he receives over a given period time. The treats are interesting for…
Description FJ has purchased N (1 <= N <= 2000) yummy treats for the cows who get money for giving vast amounts of milk. FJ sells one treat per day and wants to maximize the money he receives over a given period time. The treats are interesting for…