POJ 2181

微软Media Creation Tool 创建工具 1.3 升级:支持全新下载安装Win11 22H2 Build 22621.525 微软 Media Creation Tool 创建工具 1.3 升级:支持全新下载安装 Win11 22H2 Build 22621.525 ISO 镜像,如果今天运行使用 Media Creation Tool,则会下载 Windows 11 2022 版本 Build 22621.525,它不会向操作系统添加任何新内容,但会修复安装问题,下面来看看详细的更新内容。 阅读详情

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 doctor has mixed up P (1 <= P <= 150,000) potions to aid the cows in their quest to jump. These potions must be administered exactly in the order they were created, though some may be skipped.

Each potion has a 'strength' (1 <= strength <= 500) that enhances the cows' jumping ability. Taking a potion during an odd time step increases the cows' jump; taking a potion during an even time step decreases the jump. Before taking any potions the cows' jumping ability is, of course, 0.

No potion can be taken twice, and once the cow has begun taking potions, one potion must be taken during each time step, starting at time 1. One or more potions may be skipped in each turn.

Determine which potions to take to get the highest jump.

Input

* Line 1: A single integer, P

* Lines 2..P+1: Each line contains a single integer that is the strength of a potion. Line 2 gives the strength of the first potion; line 3 gives the strength of the second potion; and so on.

Output

* Line 1: A single integer that is the maximum possible jump.

Sample Input

872184356

Sample Output

17

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 doctor has mixed up P (1 <= P <= 150,000) potions to aid the cows in their quest to jump. These potions must be administered exactly in the order they were created, though some may be skipped.

Each potion has a 'strength' (1 <= strength <= 500) that enhances the cows' jumping ability. Taking a potion during an odd time step increases the cows' jump; taking a potion during an even time step decreases the jump. Before taking any potions the cows' jumping ability is, of course, 0.

No potion can be taken twice, and once the cow has begun taking potions, one potion must be taken during each time step, starting at time 1. One or more potions may be skipped in each turn.

Determine which potions to take to get the highest jump.

Input

* Line 1: A single integer, P

* Lines 2..P+1: Each line contains a single integer that is the strength of a potion. Line 2 gives the strength of the first potion; line 3 gives the strength of the second potion; and so on.

Output

* Line 1: A single integer that is the maximum possible jump.

Sample Input

8 7 2 1 8 4 3 5 6

Sample Output

17

#include<cstdio>
#include<algorithm>
using namespace std;
#define M 150005
int dp[M][2][2],a[M];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        for(int i=0;i<n;i++)
        {
            scanf("%d",a+i);
        }
        dp[0][0][0]=0;
        dp[0][0][1]=-900000000;
        dp[0][1][1]=a[0];
        dp[0][1][0]=-900000000;
        for(int i=1;i<n;i++)
        {
            dp[i][0][0]=max(dp[i-1][0][0],dp[i-1][1][0]);
            dp[i][0][1]=max(dp[i-1][1][1],dp[i-1][0][1]);
            dp[i][1][0]=max(dp[i-1][1][1],dp[i-1][0][1])-a[i];
            dp[i][1][1]=max(dp[i-1][0][0],dp[i-1][1][0])+a[i];
        }
        printf("%d\n",max(max(dp[n-1][0][0],dp[n-1][0][1]),
            max(dp[n-1][1][0],dp[n-1][1][1])));
    }
    return 0;
}
matlab SAR图像的多视滤波 单视复数数据(Single Look Comple)是原始的最高分辨率数据,但是从单个像元散射的雷达回波信号的相干叠加,导致强度信息有很多噪声。SAR的多视处理是对SLC数据方位向和/或距离向做平均,得到的结果是多视后的强度数据。多视处理可以提高SAR图像的信噪比,有效抑制斑点噪声,但是会降低方位分辨率。 阅读详情

相关推荐

告别版本过低提示!微信3.9登录修复与聊天记录无缝迁移全攻略

本文详细解析了微信3.9版本过低提示的根源,并提供了完整的修复方案和聊天记录迁移指南。通过专用修复工具绕过版本检测,以及新旧版本聊天记录目录对比,帮助用户实现无缝迁移。特别提醒备份重要数据,确保操作安全。

weixin_42535461的博客 3181

poj 2181 Jumping Cows

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

zark721的博客 335

直流有刷电机控制 - 认识电机(一)

电机控制学习

u011030644的博客 917

(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

Vivado Schematic视图实战:从RTL分析到布局布线,如何用它快速定位设计问题(附2019.1版操作)

本文深入解析Vivado Schematic视图在FPGA设计中的关键作用,从RTL分析到布局布线全流程,帮助工程师快速定位设计问题。通过三重视图对比、高效调试四步法和高级技巧,提升问题排查效率,缩短调试时间。文章结合2019.1版操作指南和实战案例,展示如何利用Schematic视图解决典型设计问题。

weixin_30591551的博客 490

相机通用类之海康相机,软触发硬触发(飞拍),并输出halcon格式对象

如何显示图像:可以访问我文章开头的博客,通过编写相机通用类即可,程序中是有继承通用类,通过访问相机通用的获取图像数据,从而传输图像数据。具体可以查看相机通用类。整体过程其实比较简单,由于海康相机没有像一些品牌相机一样可以直接使用序列号开启相机,所以我们需要通过对相机信息进行索引,根据索引到的相机序列号来开启相机。

m0_51559565的博客 7622

POJ 1007

#include<iostream>//#include<string>using namespace std;char chus[200][201];int a[201],b[201];int n,m,i,j,k,t;int main(){ //freopen("acm.acm","r",stdin); cin >> n >> m;...

weixin_30463341的博客 246

vit的cam和注意力图: VIT模型的可解释性

VIT的热力图怎么画

YI_SHU_JIA的博客 1万+

POJ 2181 Cows 树状数组

来源:http://poj.org/problem?id=2481 题意:有一些牛,这些牛有一个属性值,这个属性值的范围给出,为si,ei,若si = ej && ei - si > ej - sj,则称牛i是比牛j强壮的。问对于每只牛,有多少只牛比其强壮。 思路:树状数组,可以对e按升序排序,这样在j前面的e值一定比j的e值大,因此只需要考虑s值即可,就可以用树状数组了。这道题也从根本上改变

738

互联网人提高效率必备软件合集

很多的时候我们解决不了问题,只是因为没有找到对的工具,实际上,很多好的工具就在那里,只是你不用而已。这点上,信息壁垒是一个很大的原因,因此我希望兄伙伴们多出去走走,不要只是局限在一个圈层;

zhonglunshun的专栏 3485

[VCS]门级仿真及SDF反标

摘要:门级仿真在STA工具普及后仍是验证的重要环节,主要用于检查SDC完备性、异步电路时序、网表完整性及为功耗分析提供波形。门级仿真分为不带时序反标的前仿和带SDF反标的后仿,后仿需加载SDF文件提供精确延时信息。VCS提供多种仿真选项控制时序检查行为,SDF反标可通过命令或系统函数实现。后仿需特别注意关闭notimingcheck选项以确保时序检查有效性,并建议检查SDF反标报告和波形验证延时一致性。

元直的博客 9793

poj2181解题报告

一道基础的DP,题意大概是:牛们想跳上月球,但他们没办法跳跃,于是巫师发明了一些饮料,每种饮料有一个strength值,每次给出n种饮料,一种饮料只能使用一次,且必须按照给出顺序使用,假设一只牛使用了m种饮料,则它使用的第奇数种饮料(1,3,5,……)会增加牛的跳跃能力,而第偶数种饮料会降低牛的跳跃能力,求牛能跳跃的最大高度。如例子中,选择7,1,8,3,6。那么会得到7-1+8-3+6=17

waterbuffalo的专栏 962

docker-compose Install OrangeHRM

OrangeHRM是一个全面的人力资源管理HRM) 系统,它包含任何企业所需的所有基本功能。OrangeHRM旨在支持任何规模的团队,包括初创企业、中小企业以及大型跨国组织。

极致,细节 1007

POJ_2181(贪心问题)

POJ_2181,贪心问题,代码有所参考 题目思路:在数组首位插入0,然后从前往后搜,交替执行: (1)找一个比相邻两个数都大或等于的数,+; (2)找一个比相邻两个数都小或等于的数,-; #include <cstdio> int potions[150001]; int main(){ int num; scanf("%d",&num); potions[0]=0;...

宫·商的博客 296

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

[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

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

POJ2181强连通分量

<br />POJ 2181 强连通分量  (2009-07-11 00:00:00)转载标签:  强连通分量   杂谈分类: POJ解题报告<br />题目大意 :<br />有一些牛,然后他们互相仰慕,为有向图,仰慕可传递, a仰慕b, b仰慕c,a就仰慕c,让你求<br />解被所有牛仰慕的牛的个数。<br />思路:<br />先做出强连通分量,然后将一个分量作为一个节点(分量中的每一个节点都具有相同的性质),重新构图。找出是否有出度为0的点。如果出度为0的点不是一,则不存在这样的cow。<

jiangjiashi的博客 774

POJ2181

初看这道题,以为是x大水题,想了

zhb的专栏 338

poj2181

//贪心很有技巧行啊。没想到#include#includeint main(){int n,a[150001];int i,j,k;int t,sum;while(scanf("%d",&n)!=EOF){memset(a,0,sizeof(a));for(i=0;iscanf("%d",&a[i]);sum=0;k=1; for(i=0;i{if(k%2==1)//奇数的时候,加上最大的那个{if(a[i]sum+=a[i];k++; }else if(k%2==0)//偶数的时候减去最小的{if(a[

zhang20072844的专栏 754

POJ 2181 Jumping Cows

传送门:http://poj.org/problem?id=2181 题意: 有一些药水可以帮助cow跳高,你只能从左往右选择一些药水来和,根据你选择的顺序,奇数次增加跳高能力,偶数次削弱跳高能力。 解题思路: 它选择7-1+8-2+6=17 dp[i][0]:=在拿到第i瓶要前,已经拿到偶数瓶药最大值。dp[i][1]:=在拿到第i瓶要前,已经拿到奇数瓶药...

weixin_30345055的博客 75

POJ 2181-Jumping Cows

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

飘过的小牛 2110

POJ 2181 贪心

思路: 贪心 对于每个波浪 ans+=最大值-最小值注意最后一定是选最大值//By SiriusRen #include <cstdio> using namespace std; int n,a[150500],flag,ans; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++)scanf("%d",&a[i]);

SiriusRen的博客 448
下一篇: POJ 2892 树状数组+二分
MakingMaker
博客等级 码龄15年 6粉丝 108原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值