1007 Maximum Subsequence Sum (25 point(s))

TSMC40nmLP版图实战:从Design Rule解读到Cadence高效布局布线 本文详细解析了TSMC40nmLP工艺的版图设计实战,从Design Rule解读到Cadence高效布局布线技巧。重点介绍了40nm工艺中的关键设计规则,如最小线宽、间距规则和深N阱规则,并分享了Cadence Virtuoso中的高效工作流和射频模块设计技巧,帮助工程师提升版图设计效率和质量。 阅读详情

1007 Maximum Subsequence Sum (25 point(s))

Given a sequence of K integers { N​1​​, N​2​​, ..., N​K​​ }. A continuous subsequence is defined to be { N​i​​, N​i+1​​, ..., N​j​​ } where 1≤i≤j≤K. The Maximum Subsequence is the continuous subsequence which has the largest sum of its elements. For example, given sequence { -2, 11, -4, 13, -5, -2 }, its maximum subsequence is { 11, -4, 13 } with the largest sum being 20.

Now you are supposed to find the largest sum, together with the first and the last numbers of the maximum subsequence.

Input Specification:

Each input file contains one test case. Each case occupies two lines. The first line contains a positive integer K (≤10000). The second line contains K numbers, separated by a space.

Output Specification:

For each test case, output in one line the largest sum, together with the first and the last numbers of the maximum subsequence. The numbers must be separated by one space, but there must be no extra space at the end of a line. In case that the maximum subsequence is not unique, output the one with the smallest indices i and j (as shown by the sample case). If all the K numbers are negative, then its maximum sum is defined to be 0, and you are supposed to output the first and the last numbers of the whole sequence.

Sample Input:

10
-10 1 2 3 4 -5 -23 3 7 -21

Sample Output:

10 1 4

 参考链接:https://blog.youkuaiyun.com/coderwait/article/details/89676714

#include<iostream>
using namespace std;
const int MAX = 1e5+7;
int a[MAX]={0};
int main(void){
	int n;
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	int startIdx=0,endIdx=0,maxStart=0,maxEnd=0;
	int curMax = a[0];
	int max = a[0];
	for(int i=1;i<n;i++){
		if(curMax>0){
			curMax+=a[i];
			endIdx=i;
		}
		else{
			curMax=a[i];
			startIdx=i;
			endIdx=i;
		}
		if(curMax>max){
			maxStart=startIdx;
			maxEnd=endIdx;
			max=curMax;
		}
	}
	if(max<0){
		cout<<"0 "<<a[0]<<" "<<a[n-1]<<endl;
	}
	else{
		cout<<max<<" "<<a[maxStart]<<" "<<a[maxEnd]<<endl;
	}
	return 0;
	
} 

 

可控异常的契约化设计:在 ABAP 中用 CX_STATIC_CHECK 把可预期错误变成接口的一部分 文章摘要: 本文探讨了ABAP系统中异常处理的工程化设计原则,强调将可预期的业务异常作为接口契约的一部分。核心观点是:对于调用方能够合理处理的错误情况,应使用继承自CX_STATIC_CHECK的受检异常,通过方法签名强制调用方处理或显式转发。文章对比了ABAP三大异常根类的适用场景,提出"三问法"判断异常是否适合受检处理,并给出了包含上下文信息的异常类实现示例。通过Fiori文件上传案例,展示了如何在分层架构中合理传递和转换异常,最终在OData服务层将业务异常映射为标准错误响应。这种 阅读详情

相关推荐

信号完整性分析学习--16--传输线效应

传输线效应 说到传输线效应,大多数人都会想到一个经验法则,那就是: “当互连线的长度大于1/6倍的信号上升时间的空间延伸时,互连线就体现出传输线效应。” 上升时间越小越容易体现传输线效应。 由此可见,同一根互连线,它是否体现传输线效应,要看它要传输什么样的信号。下图所示,一根延时为15ps的互连线,当它传输上升时间为60ps的信号时就会体现传输线效应;当它传输上升时间为180ps的信号时就不体现传输线效应。

qq_29476769的博客 7284

1007 Maximum Subsequence Sum (25 point(s))

题解 水题。 #include&lt;iostream&gt; #include&lt;cstdio&gt; using namespace std; const int INF = 0x3f3f3f3f; int first, last, sum, temp, cnt; int n, l, a[10000]; int main() { scanf("%d", &amp;n); fo...

徐伯莱 261

LTspice仿真三线制PT100高精度测温系统设计

本文详细介绍了如何使用LTspice仿真设计三线制PT100高精度测温系统。文章从三线制原理出发,逐步讲解了在LTspice中建模PT100、构建惠斯通电桥进行信号转换、设计差分放大与滤波电路、选型ADC以及进行系统联调与误差分析的全过程,旨在帮助工程师实现0.5°C分辨率的工业测温方案设计。

pz89012345的博客 100

1007 Maximum Subsequence Sum (25)(25 point(s))(cj)

1007 Maximum Subsequence Sum (25)(25 point(s))Questions Given a sequence of K integers { N~1~, N~2~, ..., N~K~ }. A continuous subsequence is defined to be { N~i~, N~i+1~, ..., N~j~ } where 1 &lt;= i...

Cute_jinx的博客 687

AlphaFold-multimer实战:从零开始预测STAT1-STAT2蛋白复合物结构

本文详细介绍了使用AlphaFold-multimer从零开始预测STAT1-STAT2蛋白复合物结构的完整实战流程。内容涵盖环境配置、数据库准备、序列处理、参数优化及结果可信度评估,为研究者利用这一AI工具进行复合物结构预测提供了系统指南和深度解析。

weixin_29094301的博客 889

一文详解AUTOSAR COM ComSignal结构体

ComSignalLength指定信号的长度,以字节为单位,影响数据的解析范围和精度。比如车速信号若为UINT16类型,ComSignalLength=16。这里需要注意必须ComSignalLength与ComSignalType匹配(比如FLOAT32类型需配置ComSignalLength=32),超出实际物理值范围时需配置缩放(Scaling)参数。ComSignalType定义信号的物理数据类型,决定如何解析原始字节数据。

menghuyouyou的博客 943

PAT (Advanced Level) Practice 1007 Maximum Subsequence Sum (25 point(s))

题目: PAT 甲 1007 题目大意 找出最大子序列的和,并且需要保存子序列的起始元素和终止元素 思路 最大子序列和是典型的动态规划题目,转移方程为 dp[i]=max(dp[i-1]+a[i],a[i])。由于转移方程只与i-1项有关,所以只需要一个参数pre保存即可,不用定义一整个数组 代码1是没有优化的,代码2是优化的 代码1 #include<bits/stdc++.h> using namespace std; const int maxn=1e4+10; int dp[maxn

helloful的博客 149

AIGC大模型应用教学平台

该平台采用最新的AI推理加速芯片,提供30Tops算力和32GB存储,能够运行常见的大语言模型如ChatGLM2、Llama2、Baicuan、Mistral等,也可以运行文生图扩散模型Stable Diffusion,提供大模型微调、量化、转换和加速推理服务。在此基础上,平台还提供常见的生成式AI应用,包括AIGC知识抽取增强(RAG)、AIGC绘画、AIGC会话聊天、数字虚拟人等应用,以便学生能够掌握最新的生成式AI模型微调、提示工程和智能体应用技能。

中智讯的博客 1208

1007 Maximum Subsequence Sum (25 point(s))

1007 Maximum Subsequence Sum (25 point(s)) 用dp[i]=sum,vdp[i] = {sum,v}dp[i]=sum,v 表示以i结尾的连续子序列,最大的和是多少,以及开头数字是什么。然后就看每一个dp[i]dp[i]dp[i]是接着dp[i−1]dp[i-1]dp[i−1],还是以自身作为连续子序列开始,这两种方案谁的sumsumsum更大 #include <stdio.h> #include <iostream> #include &l

tobe_numberone的博客 179

【Qt开发教程】网络代理QNetworkProxy类详解及实战应用

QNetworkProxy 提供了一种灵活而强大的方式来配置和管理网络代理,通过设置代理类型、主机、端口和认证信息,可以使应用程序的所有网络请求通过代理服务器进行。结合 QNetworkProxyFactory 可以实现动态代理选择和自动配置,提高应用的网络通信能力和安全性。在实际应用中,通过合理设置代理、处理代理认证和错误情况,可以确保应用程序在复杂的网络环境中稳定运行,为用户提供可靠的网络访问体验。

科技改变人类,技术成就未来 1542

FANUC机器人通过ROBOGUIDE实现与实际的机器人进行程序导入导出的具体方法示例

FANUC机器人通过ROBOGUIDE实现与实际的机器人进行程序导入导出的具体方法示例

Robot_PLC_HMI_Automation 6544

1007 Maximum Subsequence Sum (25)(25 分)

1 题目 2 解题思路 3 AC代码 1 题目 Given a sequence of K integers { N~1~, N~2~, …, N~K~ }. A continuous subsequence is defined to be { N~i~, N~i+1~, …, N~j~ } where 1 &lt;= i &lt;= j &lt;= K. The ...

大山喵写博客的地方 975

labelImg使用教程

Anaconda环境 安装 Anaconda 之后,在开始菜单下找到 Anaconda 文件夹 找到 Anaconda Prompt 点击运行 安装 labelImg pip install labelImg #直接命令行输入 启动 labelImg labelImg #直接命令行输入名称即可 labelImg界面 开始标注 快捷键:W(创建方框),A(上一张),D(下一张) XML文件示例 <annotation> <folder>夜读</folder>

G果的博客 3万+

A1007 Maximum Subsequence Sum (25point(s))

A1007 Maximum Subsequence Sum (25point(s)) #include<cstdio> #include<algorithm> using namespace std; const int maxn = 10010; int K; int dp[maxn], s[maxn], a[maxn]; int main(){ bool fla...

LEOSATA's Blog 201

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

PAT(甲级)1007 Maximum Subsequence Sum (25point(s))

题目 题目链接 思路 题目大意:给一个数组,找到最大的连续子序列; 状态划分:以每个元素为结尾划分状态,dp[i]代表以这个元素为结尾时最大的连续子序列和,注意状态dp[i]包含第i个元素; 状态转移:对于状态i来说,可分为两种情况:加上前一状态的结果,即如果 dp[i - 1] + num[i] >= num[i],则dp[i] = dp[i - 1] + num[i];只有自己本身, 则dp[i] = num[i]; 最后遍历所有状态,找到最优; 对于题目中要求输出起点,则开一个数组start[i

hjyp的博客 204

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

1007 Maximum Subsequence Sum (25 point(s)) - C语言 PAT 甲级

设计思路: 动态规划 * 函数 f(i) 表示以第 i 个数结尾的子数列的最大和,则: * 当 i = 0 或 f(i - 1) < 0 时,f(i) = data[i]; * 当 i != 0 且 f(i - 1) >= 0 时,f(i) = f(i - 1) + data[i]; 注:输出头元素索引最小,则之前子列和为 0 的子列需要包含进来;输出尾元素索引最小,则之后子列和为 0 的子列不需要包含进来

有三只土豆 207

1007 Maximum Subsequence Sum (25)(25 point(s))

problem Given a sequence of K integers { N~1~, N~2~, ..., N~K~ }. A continuous subsequence is defined to be { N~i~, N~i+1~, ..., N~j~ } where 1 <= i <= j <= K. The Maximum Subsequence is the ...

weixin_30691871的博客 104

PAT(A) 1007 Maximum Subsequence Sum (25 point(s)) C++ 动态规划

动态规划 个人理解:temp是从i开始的每个data[i]的和,把temp看做序列第一个数,若temp是负数,则舍弃,从下一个数开始重新计算temp;若temp是正数,则采用,比较记录最大的sum #include <cstdio> int main(void){ int K, data[10001], start = -1, end, sum = -1; scanf("%d", &K); for(int i = 0; i < K; i++)

Anpotan的博客 120

PAT甲级练习1007 Maximum Subsequence Sum最大连续子序列和 (25 point(s))

题目 题解 个人见解 #include <bits/stdc++.h> using namespace ::std; const int maxn = 10005; int dp[maxn], a[maxn]; int main() { int n; cin >> n; for(int i = 1; i <= n; ++i) //读入 cin >> a[i]; dp[1] = a[1]; //边界值 i

RainGiving的博客 263

Python 实现1007. Maximum Subsequence Sum (25)

1007. Maximum Subsequence Sum (25)Given a sequence of K integers { N1, N2, …, NK }. A continuous subsequence is defined to be { Ni, Ni+1, …, Nj } where 1 <= i <= j <= K. The Maximum Subsequence is the

期待一份好工作 508

1007 Maximum Subsequence Sum (25分) Python解法

Given a sequence of K integers { N​1, N​2​​ , …, N​K}. A continuous subsequence is defined to be { N​i, N​i+1, …, N​j} where 1≤i≤j≤K. The Maximum Subsequence is the continuous subsequence which has the largest sum of its elements. For example, given sequen

Jay_fearless的博客 328

【PAT】1007 Maximum Subsequence Sum (25) 最大连续子序列和 +记录位置

题目 Given a sequence of K integers { N1, N2, ..., NK }. A continuous subsequence is defined to be { Ni, Ni+1, ..., Nj } where 1 Maximum Subsequence is the continuous subsequence which has the la

wwk0125的专栏 1102

每日一道算法题 Day6 of PAT 1007 Maximum Subsequence Sum (25分)

1007 Maximum Subsequence Sum (25分) Given a sequence of K integers { N​1​​ , N​2​​ , …, N​K​​ }. A continuous subsequence is defined to be { N​i​ , N​i+1​​ , …, N​j​​ } where 1≤i≤j≤K. The Maximum Sub...

weixin_43661154的博客 202

1007. Maximum Subsequence Sum (25) -- 动态规划

1007. Maximum Subsequence Sum (25)题目地址Given a sequence of K integers { N1, N2, …, NK }. A continuous subsequence is defined to be { Ni, Ni+1, …, Nj } where 1 <= i <= j <= K. The Maximum Subsequence is

master-dragon的专栏 1612

PAT1007. Maximum Subsequence Sum (25)

Maximum Subsequence Sum (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given a sequence of K integers { N1, N2, …, NK }. A continuous subsequence is defined to be...

博客 268

1007 Maximum Subsequence Sum(25 分)【最大连续子序列和】

题意:求最大连续子序列和并记录该序列的头尾元素 #include &lt;bits/stdc++.h&gt; using namespace std; int N; int main() { cin&gt;&gt;N; vector&lt;int&gt; v(N); int l=0,r=N-1,sum=-1,temp=0,tl=0; for(int i=0;...

1040
上一篇: 1009 Product of Polynomials (25 point(s))
下一篇: 1005 Spell It Right (20 point(s))
coderwait
博客等级 码龄9年 20粉丝 210原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值