NEFU 654 Magic Tree(DP)

本文概述了AI音视频处理领域的关键技术,包括视频分割、语义识别、自动驾驶、AR、SLAM、物体检测与识别、语音识别与变声等,深入探讨了AI在音视频处理中的应用与最新进展。
部署运行你感兴趣的模型镜像

Magic Tree

Time Limit 1000ms

Memory Limit 65536K

description

  Every acmer dream for gold medal. Fotunately,there are two magic trees (which are conveniently numbered 1 and 2) in our campus, each full of gold medal. The trees are very high, so we can not touch the gold medal when they are in the tree but wait for them to fall. However, we must catch them in the air since the gold medal disappear when they hit the ground. 	Each minute, one of the two magic trees drops a medal. we can catch an medal if we are standing under a tree from which one falls. The magic tree 1 is near by the magic tree 2.So we can walk between the two trees quickly (in much less than a minute), we can stand under only one tree at any time. Moreover, we are not willing to walk back and forth between the trees endlessly (and thus misses some gold medal). 	Medal fall (one each minute) for T (1 ≤ T ≤ 1,000) minutes. We are willing to walk back and forth at most W (1 ≤ W ≤ 30) times. Given which tree will drop an medal each minute, determine the maximum number of medal which we can catch. We starts at magic tree 1.
							

input

Line 1: Two space separated integers: T and W Lines 2~T+1: 1 or 2, the tree that will drop a medal each minute.
							

output

Line 1: The maximum number of medal we can catch without running more than W times.
							

sample_input

7 2
2
1
1
2
2
1
1
							

sample_output

6
							

hint

INPUT DETAILS: 	Seven medal fall - one from tree 2, then two in a row from tree 1, then two in a row from tree 2, then two in a row from tree 1.We are willing to walk from one tree to the other twice. OUTPUT DETAILS: 	We can catch six medals by staying under tree 1 until the first two have dropped, then moving to tree 2 for the next two, then returning back to tree 1 for the final two.
								
							

source

思路: dp[x][y][z] 第x个时刻还可以跳y次,最后一次接到z的最优值

if(当前是z)

dp[x][y][z]=min(dp[x-1][y][z]+1,dp[x-1][y+1][z^1]+1);

else 

dp[x][y][z]=min(dp[x-1][y][z],dp[x-1][y+1][z^1])

注意点:起始点可以是随意哪个点


#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int dp[1010][50][2];
int f[1010];
int main()
{
  int n,m;
  while(~scanf("%d%d",&n,&m))
  { int x;
    memset(dp,0,sizeof(dp));

    for(int i=1;i<=n;++i)
    {
      scanf("%d",&f[i]);
    }
    int ans=0;
    for(int i=1;i<=n;++i)
    {
      for(int j=0;j<=m;++j)
        if(f[i]==1)
        {
          dp[i][j][0]=dp[i-1][j][0]+1;
          if(j<m)
            dp[i][j][0]=max(dp[i][j][0],dp[i-1][j+1][1]+1);
          dp[i][j][1]=dp[i-1][j][1];
          if(j<m)
            dp[i][j][1]=max(dp[i][j][1],dp[i-1][j+1][0]);
          ans=max(ans,dp[i][j][0]);
          ans=max(ans,dp[i][j][1]);
        }
        else
        { dp[i][j][1]=dp[i-1][j][1]+1;
          if(j<m)
            dp[i][j][1]=max(dp[i][j][1],dp[i-1][j+1][0]+1);
          dp[i][j][0]=dp[i-1][j][0];
          if(j<m)
            dp[i][j][0]=max(dp[i][j][0],dp[i-1][j+1][1]);
          ans=max(ans,dp[i][j][0]);
          ans=max(ans,dp[i][j][1]);
        }
       /// for(int i=)
    }
    printf("%d\n",ans);
  }
}




您可能感兴趣的与本文相关的镜像

Langchain-Chatchat

Langchain-Chatchat

AI应用
Langchain

Langchain-Chatchat 是一个基于 ChatGLM 等大语言模型和 Langchain 应用框架实现的开源项目,旨在构建一个可以离线部署的本地知识库问答系统。它通过检索增强生成 (RAG) 的方法,让用户能够以自然语言与本地文件、数据库或搜索引擎进行交互,并支持多种大模型和向量数据库的集成,以及提供 WebUI 和 API 服务

内容概要:本文介绍了一个基于Matlab的综合能源系统优化调度仿真资源,重点实现了含光热电站、有机朗肯循环(ORC)和电含光热电站、有机有机朗肯循环、P2G的综合能源优化调度(Matlab代码实现)转气(P2G)技术的冷、热、电多能互补系统的优化调度模型。该模型充分考虑多种能源形式的协同转换与利用,通过Matlab代码构建系统架构、设定约束条件并求解优化目标,旨在提升综合能源系统的运行效率与经济性,同时兼顾灵活性供需不确定性下的储能优化配置问题。文中还提到了相关仿真技术支持,如YALMIP工具包的应用,适用于复杂能源系统的建模与求解。; 适合人群:具备一定Matlab编程基础和能源系统背景知识的科研人员、研究生及工程技术人员,尤其适合从事综合能源系统、可再生能源利用、电力系统优化等方向的研究者。; 使用场景及目标:①研究含光热、ORC和P2G的多能系统协调调度机制;②开展考虑不确定性的储能优化配置与经济调度仿真;③学习Matlab在能源系统优化中的建模与求解方法,复现高水平论文(如EI期刊)中的算法案例。; 阅读建议:建议读者结合文档提供的网盘资源,下载完整代码和案例文件,按照目录顺序逐步学习,重点关注模型构建逻辑、约束设置与求解器调用方式,并通过修改参数进行仿真实验,加深对综合能源系统优化调度的理解。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值