POJ 2181 Jumping Cows

保姆级教程:用Docker一键部署vLLM大模型推理服务(附常见报错解决方案) 本文提供了一份详细的Docker化vLLM大模型推理服务部署指南,涵盖从环境准备到性能调优的全流程。通过容器化技术解决大语言模型部署中的显存利用率、吞吐量等核心问题,并附常见报错解决方案,帮助开发者快速构建高效、可扩展的AI推理服务。 阅读详情

       给你n个药的序列,牛从时间1开始吃药,在奇数时间吃药可以增加弹跳力,在偶数时间吃药则会减少弹跳力。在某一时间,你可以跳过一些药,但一旦吃过某种药,你就不能在选前面的药了。问你某一个吃药的序列,使牛最终的弹跳力最大。

       解法有多种,可以dp,可以贪心。

动态规划:

       dp[i][0] 表示 当拿到第i个药时,之前已经拿了奇数个药的最大弹跳力。

       dp[i][1] 表示 当拿到第i个药时,之前已经拿了偶数个药的最大弹跳力。

       方程就是,

       dp[i][0] = max(dp[i-1][0], dp[i-1][1]- v[i]);
       dp[i][1] = max(dp[i-1][1], dp[i-1][0]+v[i]);

贪心解法:

       把原序列分割成若干个小段,保证每个小段最大值在最小值之前,而每次吃药的时候就先吃最大值,再吃最小值,就能保证弹跳力在不断的增加。

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int dp[151000][2];
int maxd(int a,int b)
{
    return a<b?b:a;
}
int main()
{
    int n,i,t;
    while (scanf("%d",&n) != EOF)
    {
        dp[0][0]=0;
        dp[0][1]=0;
        for (i=1; i<=n; i++)
        {
            scanf("%d",&t);
            dp[i][0]=maxd(dp[i-1][0],dp[i-1][1]-t);
            dp[i][1]=maxd(dp[i-1][1],dp[i-1][0]+t);
        }
        printf("%d\n",maxd(dp[n][0],dp[n][1]));
    }
}


在 SAP S/4HANA 的 BP 事务里做保存前校验:BDT 事件、BUPA_FURTHER_CHECKS 与 CVI 扩展 BAdI 一次讲透 SAP BP事务保存前校验机制解析 摘要:本文系统梳理了SAP BP事务保存前的校验机制,揭示了三种关键校验点的差异与适用场景: BDT框架DCHCK事件:最靠近UI层,适合屏幕字段级校验,但API调用时可能失效 Classic BAdI BUPA_FURTHER_CHECKS:全局拦截点,可阻断整个BP保存,适合核心业务规则 CVI扩展校验:仅管控供应商/客户段落,需注意可能产生"BP已保存但段落未保存"的情况 文章通过真实案例(如黑名单校验、付款冻结等)展示了各校验点的最佳实践,并特 阅读详情

相关推荐

DCM4CHEE Archive Light 应用配置-存储配置

本文介绍了在DICOM归档系统中配置和管理存储的方法,包括通过用户界面和LDAP导入两种方式。主要内容包括: 存储配置概述:用户可根据需求配置单个或多个存储设备,支持在磁盘空间不足或多任务并行时使用。存储分为Archive设备级(序列元数据存储)和Application Entity级(对象存储/元数据存储)。 用户界面操作: 设备级存储配置:通过菜单导航添加/编辑存储描述符,设置Storage ID、URI等关键参数 应用级存储引用:在设备扩展和网络AE中分别配置元数据和对象存储引用 LDAP配置方法:

洪城叮当的博客 1423

牛客-超级跳

要是为负的话,是Math.max(后一个数为负状态的值,后一个数为正状态的值加上这个负数的值),要是为正的话,是Math.max(后一个数为正状态的值,后一个数为负状态的值加上这个正数的值)。最后是cache[0][1],因为第一个状态一定是正数状态。链接:https://www.nowcoder.com/questionTerminal/2ae94400de4e409c91c3470a95681bfc。初始的时刻是从1开始的,Abby初始的弹跳能力是0,当然我们的Abby总想尽可能的跳的高一些。.....

nice___amusin的博客 590

基于MicroBlaze与LWIP的FPGA以太网通信实战指南

本文详细介绍了基于MicroBlaze软核处理器与LWIP协议栈的FPGA以太网通信实现方案。通过Vivado工具链配置硬件设计,结合LWIP轻量级TCP/IP协议栈优化,提供高效、低成本的嵌入式网络解决方案,适用于工业控制等场景。文章包含硬件设计、软件配置及常见问题排查等实战指南。

weixin_29290863的博客 542

Jumping Cows(线性DP)

Farmer John’s cows would like to jump over the moon, just like the cows in their favorite nursery rhyme. Unfortunately, cows can not jump. The local witch doctor has mixed up P (1 <= P <= 150,0...

li_wen_zhuo的博客 559

MUJOCO+AUBO机械臂+强化学习+路径规划

最近在学习机械臂强化学习路径规划,参考了知乎教程。由于原教程较老(使用stable baselines3+panda-gym),新版本变化了,我略做调整,记录写在。上面这个教程用的是官方,环境封装较死(类似),最终基于重新开发。代码已开源至github:https://github.com/YellowThree-HS/mujoco-Aubo-RL-PathPlanning。

qq_63308550的博客 2051

半结构化访谈法完全指南:从提纲设计到洞察提取的实操技巧

用户研究和需求调研中,如何从受访者获取真实、深入的信息是核心挑战。半结构化访谈法通过提纲兜底、动态追问和弹性收束三大机制,在保证核心议题覆盖的同时捕捉意外洞察,成为定性研究的关键技术。其技术价值在于平衡数据系统性与深度挖掘,广泛应用于产品需求挖掘、组织诊断和学术田野调查等场景。掌握追问技巧、提纲编写和编码分析方法,能有效提升访谈质量,避免常见翻车现场,实现从录音到洞察的高效转化。

weixin_42522009的博客 261

Jumping Cows(谢庆皇)解题报告

大意:一群牛想要跳到月亮上面去,但是他们现在跳的能力为零。现在给你一些药水,能改变他们跳的能力。不能改变药水的顺序。当跳奇数跳的时候,就增加,当跳偶数跳的时候就减少。药水是可以跳过不喝的。 先开始想的是把最大值最小值用一个二维数组表示,结果怎么想都想不出来,主要还是想到了要记步数,后来才去看解题报告,上面说什么开个二维数组,可以表示奇数步和偶数步。 选与不选这个问题,在代码里面说明吧~~~

谢庆皇的专栏 924

探索Python融合地学:一文解决osgeo库安装失败问题

总结一下,要安装osgeo模块,关键在GDAL依赖库的安装,如果能够顺利安装GDAL依赖库,因其是osego的模块,因此osgeo的部分模块也能够得到自动安装,此时再运行代码,发现代码并不报错,能够正常运行了。第一步,我们要安装imagecodecs库,它支持多种常见的图像格式,当然也包含我们的目标tif格式,为方便后续的图像处理和安装osgeo模块,先安装此库。目前GDAL已经更新到了3.10版本,这里主要看你的Python版本是上面,小编用的是Python3.13,电脑是64位的,因此,我们选择。

Promising_GEO的博客 5469

poj 2181 Jumping Cows

原题: http://poj.org/problem?id=2181 思路:有p个数,每个数都是正数,从左到右 每次我们可以从中选1个数,在第偶数次选中的数,我们要减去arr[i],在奇数次选中的数,我们可以加上它arr[i],问最后能够得到的结果最大是多少? 思路:ou[i]表示前i个取偶数个的得到最大值 , ji[i]表示前i个取奇数个的得到的最大值 如果第i个数是奇数次被选到的

zark721的博客 337

C#串口通信从入门到精通(5)——打开、关闭串口

本文详细介绍如何打开串口

qq_34059233的博客 6792

YOLO 系列专栏(二十九)YOLO26 × StarNet 轻量化涨点方案(CVPR 2024)轻量化、主干改进篇 | 星星卷积虽小,却蕴藏着巨大的高效潜力

StarNet 出自 CVPR 2024 轻量化主干网络工作,核心创新是,依靠逐元素乘法实现高阶特征融合,在几乎不增加参数量与 FLOPs 的前提下,大幅提升特征表达能力,天然适合等多任务统一建模。本文将 StarNet 完整替换 YOLO26 原有主干,保留 YOLO26 无 NMS 检测头与轻量化结构,实现,并提供。

qq_36130719的博客 414

OJ:Jumping Cows(C++)

描述 Farmer John's cows would like to jump over the moon, just like the cows in their favorite nursery rhyme. Unfortunately, cows can not jump. The local witch doctor has mixed up P (1 <= P <= 15...

fun_always的博客 426

使用C#实现Padim算法的训练和推理:智能缺陷检测的前沿技术

Padim (Patch-based Deep Image Model) 是一种用于无监督异常检测的深度学习算法。它通过提取图像中的局部特征(patch),并在这些特征上构建一个正常样本的分布模型来识别异常。无监督学习:不需要标注数据,适用于缺乏标签的情况。局部特征提取:通过卷积神经网络提取图像的局部特征(patch)。低秩近似:利用低秩近似构建正常样本的协方差矩阵,有效降低计算复杂度。鲁棒性强:能够处理多种类型的缺陷和噪声。

墨夶的博客 1018

[poj 2181]jumping cows

poj 2181 Jumping Cows Description Farmer John's cows would like to jump over the moon, just like the cows in their favorite nursery rhyme. Unfortunately, cows can not jump. The local witch doc...

weixin_30417487的博客 187

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

POJ 2181-Jumping Cows

题目: http://poj.org/problem?id=2181 大意: 给你n个数,让你找出一个子序列,子序列计算的规则是:奇数次运算则加上这个数,偶数次运算就减去这个数。 求这个子序列的最大值。 思路: 跟物理上的波一样: 如果为区间最大值,则为波峰。则

飘过的小牛 2112

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

POJ 2181 Jumping Cows [贪心]

题意:  给定一个数字串,按奇偶顺序挑选几个数字,+奇选的数字-偶选的数字,问怎样顺序挑选使最后的和最大。 思路: O(n)贪心。 本质上其实是在对这个串进行分割,分割成若干段,每个段里面有一个最大值,一个最小值,且最大值在最小值前面。 O(N)去遍历,先找出最大值,然后找出最小值,就算完成一个子段。 至于最后的子段肯定是只有最大值,所以只需在读取的串最后面加一个数字0即可。

Aszxqw 943

全球国家地区城市数据

MySQL全球国家地区城市数据报。。。。。。。。。。。。

poj 2181 Jumping Cows 贪心

题意: 求一个序列的子序列 这个子序列的偶次项取相反数 问最大的子序列和 分析: 把每个数按其大小为y坐标那么可以得到一个类似波浪的图形,那么每次我们加上波峰减去波谷就是最优解 ACcode: #include #include #include #include #include #define maxn 151000 #define inf 0x3f3f3f3f using

MY Blog 425

poj 2181 Jumping Cows DP

题意:一群牛的初始跳跃高度为0,一些药能提高它们的跳跃能力,奇数次服用药是提高跳跃能力,偶数次降低,求最高高度 思路:见注释 #include using namespace std; const int MAX = 150005; int dp[MAX][2],nu

deng_yu的专栏 335

【POJ】2181-Jumping Cows 贪心

http://poj.org/problem?id=2181给n个数,找出一个子序列,其规则是:奇数位置+,偶数位置- 。 求这个子序列的最大值。直接贪心#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using namespace std;int a[15

西瓜不甜的博客 411

(POJ) 2181 Jumping Cows

传送门 这个题有两种解法。 第一种贪心:总是只选择最低点和最高点。这样对答案的贡献肯定是最大的。 #include&lt;iostream&gt; #include&lt;algorithm&gt; using namespace std; const int maxn=150000+5; int p; int t[maxn]; int main() { while(cin&gt;&gt...

一只不争气的蒸汽机的博客 374

POJ-2181 Jumping Cows(贪心)

POJ-2181 Jumping Cows(贪心)

Dacc123的博客 763

poj 2181 Jumping Cows 【简单DP】

//dp[i][0]=max(dp[i-1][1]-a[i],dp[i-1][0]); //dp[i][1]=max(dp[i-1][0]+a[i],dp[i-1][1]); #include #include using namespace std; const int maxn=200000; int dp[maxn][2],a[maxn]; int main() { int p;

beat anyone if necessary 514
上一篇: BNUOJ 4139 Cow Toll Paths
下一篇: POJ 3256 Cow Picnic
plusplus7
博客等级 码龄15年 59粉丝 173原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值