bzoj3384&&1750: [Usaco2004 Nov]Apple Catching 接苹果
来源:互联网 发布:飞升阵法升级数据 编辑:程序博客网 时间:2024/06/16 04:57
比较水的dp。
#include<iostream>#include<cstdio>#include<cstring>using namespace std;int maxx(int x,int y){ return x>y?x:y;}int f[1005][35][2],a[1005],ans;int main(){ int t,w; scanf("%d%d",&t,&w); for(int i=1;i<=t;i++) scanf("%d",&a[i]); for(int i=1;i<=t;i++) { f[i][0][0]=f[i-1][0][0]+(a[i]==1); f[i][0][1]=f[i-1][0][1]+(a[i]==2); for(int j=1;j<=w;j++) { f[i][j][0]=max(f[i-1][j-1][1],f[i-1][j][0])+(a[i]==1); f[i][j][1]=max(f[i-1][j-1][0],f[i-1][j][1])+(a[i]==2); ans=max(ans,max(f[i][j][0],f[i][j][1])); } } cout<<ans;}
阅读全文
0 0
- bzoj3384&&1750: [Usaco2004 Nov]Apple Catching 接苹果
- BZOJ 3384: [Usaco2004 Nov]Apple Catching 接苹果/BZOJ 1750: [Usaco2005 qua]Apple Catching dp
- USACO 2004 Nov Apple Catching 接住苹果
- Apple Catching
- Apple Catching
- Apple Catching
- POJ 2385 Apple Catching(牛吃苹果)
- 1750: [Usaco2005 qua]Apple Catching (动态规划)
- BZOJ[1750/3384]: [Usaco2005 qua]Apple Catching
- pku 2385 Apple Catching
- pku2385 Apple Catching
- poj2385 - Apple Catching
- Apple Catching 简单DP
- POJ 2385 Apple Catching
- POJ-2385-Apple Catching
- poj 2385 Apple Catching
- POJ2385 Apple Catching
- POJ 2385 Apple Catching
- React native ios 打包到手机运行
- Leetcode题解
- 第7章 分支
- RG_3
- PAT+乙1006. 换个格式输出整数
- bzoj3384&&1750: [Usaco2004 Nov]Apple Catching 接苹果
- MySQL---操作数据表基本操作(增删改查)
- 当项目中出现找不到明明存在的类的时候的解决方案
- Mybatis源码分析-数据源
- hive在centos7上安装
- C#快速排序
- 【ChinaNews】3.MySQL的基本使用
- bzoj1191: [HNOI2006]超级英雄Hero
- 从相册和相机选择图片以及图片压缩和android7.0相机