记忆化搜索

#include<bits/stdc++.h>
using namespace std;
#define maxn
int dp[105][30][5],a[105],n,m;
vector<int>v;
int dfs(int now,int sta,int rest)
{if(rest>=2) //休息2次及以上产生的效果是一样的rest=2,sta=0;if(dp[now][sta][rest]) return dp[now][sta][rest];int tmp=0;if(now>n) return dp[now][sta][rest]=tmp;if(sta==0)tmp=dfs(now+1,sta,rest+1);elsetmp=dfs(now+1,sta-1,rest+1);if(v[sta]!=0)// 防止出现调用v[sta]越界,顺便剪枝了tmp=max(tmp,dfs(now+1,sta+1,0)+min(v[sta],a[now]));return dp[now][sta][rest]=tmp;
}
int main()
{scanf("%d %d",&n,&m);for(int i=1;i<=n;i++)scanf("%d",&a[i]);int tmp=m;v.clear();v.push_back(tmp);while(tmp){tmp=tmp*2/3;v.push_back(tmp);}printf("%d\n",dfs(1,0,0));return 0;
}

G - A Question of Ingestion Gym - 101673G相关推荐

  1. A Question of Ingestion

    5028: A Question of Ingestion 时间限制: 1 Sec  内存限制: 128 MB 提交: 89  解决: 24 [提交] [状态] [讨论版] [命题人:admin] 题 ...

  2. 2021-01-25广州大学ACM寒假训练赛解题心得

    https://vjudge.net/contest/419545 目录 A - Airplane AtCoder - abc129_a B - Balance AtCoder - abc129_b ...

  3. Django入门教程(二)

    建议直接阅读末尾!!! Writing your first Django app, part 2 本节将设置数据库,创建您的第一个模型(model),并简单介绍Django自动生成的管理页面. 数据 ...

  4. 全国小学四则运算1.0

    程序:全国小学四则运算1.0 源代码: import javax.swing.*; import java.awt.*; import java.awt.event.*; //一开始的界面 publi ...

  5. [翻译]Django tutorial, part 1: Models

    编写你的第一个Django app, part I 让我们通过一个例子来学习. 贯穿这个教程,我们将带你了解一个基本的poll应用的创建. 它将由两部分组成: 一个让人们可以查看投票结果并在其中投票的 ...

  6. Django使用Python操作数据库 --Django 1.8.2 文档(中文)部分笔记

    原文网址 http://python.usyiyi.cn/django/intro/tutorial01.html 最好看过原文再阅读 model创建大致如下 #encoding=utf-8 from ...

  7. 【英语学习】【Daily English】U04 Neighborhood L01 Anything else around?

    Word Preparation right behind it:就在它后方 Did you see the post office across the street? The bank is ri ...

  8. 《人类简史》这本烧脑书风靡全球的秘密是什么?

    今日导读 十万年前,地球上至少有六种不同的人.但今日,世界舞台为什么只剩下了我们自己?从只能啃食虎狼吃剩的残骨的猿人,到跃居食物链顶端的智人,从认知革命.农业革命,到科学革命.生物科技革命,我们如何登 ...

  9. 2020年 ICLR 国际会议最终接受论文(poster-paper)列表(二)

    来源:AINLPer微信公众号(点击了解一下吧) 编辑: ShuYini 校稿: ShuYini 时间: 2020-02-21     2020年的ICLR会议将于今年的4月26日-4月30日在Mil ...

  10. Comparison of Big Data OLAP DB : ClickHouse, Druid, and Pinot

    In this post I want to compare ClickHouse, Druid, and Pinot, the three open source data stores that ...

最新文章

  1. 批处理如何做到等待用户输入一个值(dos命令行)
  2. hdu4965 巧用矩阵乘法结合律
  3. python控制手机自动刷新闻_Python脚本利用adb进行手机控制的方法
  4. python 程序运行插件_如何使Python插件在Pluma中运行?
  5. solr4 mysql自动更新_(solr系列:五) solr定时实时重建索引和增量更新
  6. 同時啟動多個Tomcat服務器
  7. java io .log_namenode无法启动:java.io.FileNotFoundException: .log (Permission denied)
  8. http响应状态码大全
  9. 精选CSDN的ACM-ICPC专栏
  10. hadoop菜鸟教程 Hadoop学习资料(云计算学习电子书)
  11. 计算机网络原理(04741)课后习题答案
  12. 如何清理驱动人生的新闻弹窗
  13. WEB UI设计尺寸规范
  14. vue 环境搭建踩坑(renren-fast 前端在windows10上部署)
  15. Windows域内密码凭证获取 (゚益゚メ) 渗透测试
  16. 如何用java获取网页源代码
  17. storm架构及原理详解
  18. Syntax error, annotations are only available if source level is 1.5 or greater错误
  19. wxid 微信号设置隐私 微信号搜不到 恢复好友总结
  20. #智能制造#第一章 智能制造,缘何而起?

热门文章

  1. cibersortx怎么用_如何使用Xbrowser
  2. 【数学】欧拉恒等式:史上最完美的数学公式,没有之一!
  3. 删除桌面计算机,桌面上的图标删不掉怎么办【解决方法】
  4. <Healing Psoriasis The Natural Alternative>笔记(持续进行中)
  5. Nanopore 纳米孔 测序数据处理 微生物 16S全长 Centrifuge的安装和使用
  6. hp-unix操作系统root账号被锁定的两种解决方法:
  7. shiro反序列化漏洞
  8. 数仓建模—元数据管理
  9. iMac一体机安装苹果和Win7双系统
  10. twitter验证_如何在Twitter上进行验证(或至少尝试一下)