1750: [Usaco2005 qua]Apple Catching (动态规划)
来源:互联网 发布:淘宝首页导航怎么去掉 编辑:程序博客网 时间:2024/05/17 23:26
#include <stdio.h>#include <iostream>using namespace std;int num[1005];int dp[1005][35][2];int main(){ int n, times, maxsum = -1; scanf("%d%d", &n, ×); for (int i = 1; i <= n; i++) { scanf("%d", &num[i]); } for (int i = 1; i <= n; i++) { dp[i][0][0] = dp[i - 1][0][0] + (num[i] == 1); dp[i][0][1] = dp[i - 1][0][1] + (num[i] == 2); for (int j = 1; j <= times; j++) { dp[i][j][0] = max(dp[i - 1][j - 1][1], dp[i - 1][j][0]) + (num[i] == 1); dp[i][j][1] = max(dp[i - 1][j - 1][0], dp[i - 1][j][1]) + (num[i] == 2); maxsum = max(maxsum, max(dp[i][j][0], dp[i][j][1])); } } printf("%d\n", maxsum); return 0;}
0 0
- 1750: [Usaco2005 qua]Apple Catching (动态规划)
- BZOJ[1750/3384]: [Usaco2005 qua]Apple Catching
- bzoj1750 [Usaco2005 qua]Apple Catching
- BZOJ 3384: [Usaco2004 Nov]Apple Catching 接苹果/BZOJ 1750: [Usaco2005 qua]Apple Catching dp
- pku2385 Apple Catching (动态规划)
- POJ2385 Apple Catching 动态规划
- 【动态规划】poj2385 Apple Catching
- poj Apple Catching(动态规划)
- POJ2385 Apple Catching——动态规划
- POJ - 2385 Apple Catching(动态规划)
- poj 2385 Apple Catching(动态规划)
- POJ2385——Apple Catching(动态规划)
- POJ 2385 Apple Catching 动态规划
- 动态规划 III——B - Apple Catching
- Apple Catching
- Apple Catching
- Apple Catching
- bzoj1754 [Usaco2005 qua]Bull Math
- Linux php/php-fpm 安装,配置
- oracle with使用
- 地方规定法规电饭锅电饭锅电饭锅地方高
- 谁知道撒地方撒大师大师大师大师
- Unique Binary Search Tree
- 1750: [Usaco2005 qua]Apple Catching (动态规划)
- JQuery,ajax同步异步设置潭
- C++和 C
- IT忍者神龟之Html规范
- 面试三
- 数学之路-python计算实战(10)-机器视觉-透视投影
- hdfs 查看文件(第一个hadoop程序)
- 地方地方法规的非官方的法规法规法规搞好
- poj1019