POJ 2385 - Apple Catching [DP]
2015-04-06 21:02
423 查看
比赛时不会动规,现在拿出来再做一遍。
dp[i][j]表示在i时刻使用j次转移得到的最多苹果数
#include <iostream> #include <cstring> #include <cstdio> using namespace std; int a[1024], dp[1024][35]; int main() { int n, w; cin >> n >> w; for(int i = 1; i <= n; ++i){ cin >> a[i]; if(a[i] == 1) dp[i][0] = dp[i-1][0] + 1; } for(int i = 1; i <= n; ++i) for(int j = 1; j <= w; ++j) dp[i][j] = max(dp[i-1][j-1] + (a[i]==j%2+1), dp[i-1][j] + (a[i]==j%2+1)); cout << dp [w] << endl; return 0; }
相关文章推荐
- poj 2385 Apple Catching 经典dp
- poj 2385 Apple Catching 简单DP
- POJ 2385 Apple Catching(基础DP)
- POJ_2385 Apple Catching(DP)
- poj 2385Apple Catching(简单dp)
- POJ 2385 Apple Catching (dp)
- POJ 2385 Apple Catching(DP)
- POJ - 2385 Apple Catching (DP)
- POJ2385 Apple Catching(DP/递推)
- POJ 2385 Apple Catching (DP)
- Apple Catching (poj 2385 简单dp)
- [POJ 2385]Apple Catching[DP]
- POJ 2385 Apple Catching(线性DP)
- POJ 2385 Apple Catching (DP)
- poj 2385 Apple Catching(dp)
- POJ 2385 Apple Catching 接苹果 DP
- POJ2385 Apple Catching (dp)
- poj 2385 Apple Catching 基础dp
- POJ 2385 Apple Catching(DP)
- POJ_2385_Apple Catching_简单DP