#include<stdio.h>#define min -99999999int sta,end;int main(){ int n,i,j,t,sum,maxsum
转载 2012-08-17 15:31:00
29阅读
2评论
题目大意:给出n个数,求出其中连续子序列和最大 ac代码: #include using
原创 2021-12-01 15:48:27
86阅读
题 题意 需要在o(n)时间内,求最大连续的子序列的和,及其起点和终点。 分析 一种方法是一边读,一边维护最小的前缀和 s[i] ,然后不断更新 ans = max(ans,s[j] - s[i]),以及起始位置。 另一种方法是尺取(算是吧),l 和 r 代表起点和终点,一开始l=0,r=1,如果s
原创 2021-07-22 14:03:58
99阅读
同上题一样,求连续子序列的最大和而且比上题还要简单一些,用不到long long了直接水过 1 //#define LOCAL 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int maxn = 10000...
转载 2014-07-24 13:31:00
47阅读
2评论
Max SumTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 26441    Accepted Submission(s): 5582Problem DescriptionGivena sequence
原创 2021-08-20 15:10:59
39阅读
HDU_1003 最大和的子串是具有这个一个特征的,从左边第一个元素开始逐个累加,每次得到的和一定是大于等于0的,因为如果某一时刻小于0,那么前面一段我们可以抛弃,而后面一段的和一定是大于目前记录的最大和的,这样就矛盾了。 然后我们根据这一特征去寻找最大和的子串即可。 #include<stdio.h>#include<string.h>int main(){int i,
转载 2011-09-25 22:14:00
85阅读
2评论
Problem Description Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7
转载 2017-03-01 23:21:00
40阅读
2评论
Max SumTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 199419    Accepted Submission(s): 46633Problem DescriptionGiven a sequenc
原创 2022-08-10 21:35:04
55阅读
Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in th...
原创 2021-07-29 16:17:00
204阅读
Max Sum Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 208607 Accepted Submission(s): 48835 Pro
转载 2016-05-10 08:43:00
36阅读
2评论
Problem Description Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7
转载 2018-10-06 22:42:00
29阅读
Problem Description Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7
转载 2016-03-12 08:06:00
46阅读
2评论
Max SumTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s):onGiven a sequenc
原创 2023-07-18 19:11:11
38阅读
                                 &n
原创 2013-07-26 17:39:00
357阅读
Max Sum-HDU1003#include<bits/stdc++.h>using namespace std;#define IOS ios::sync_with_stdio(false),cin.tie(0)
原创 2022-07-11 17:03:59
65阅读
题目地址:HDU 1003DP好弱。。先补补DP的基础。。。这题就是记录起始点与终止点,然后每当发现一个更大的,就更新。从左往右扫一遍就行了。代码如下:#include #include #include #include #include #include #include #include #include #include #include using
原创 2023-04-14 00:20:07
23阅读
Problem DescriptionGiven a sequence a[1],a[2],a[3]......a[n], your job is to cal
原创 2023-03-02 09:16:11
36阅读
 #include <iostream> #include<stdio.h> #include<stdlib.h> using namespace std; int main() { int t; scanf("%d",&t); for(int i=0;i<t;i++) { int n; sca
原创 2021-08-06 15:32:36
127阅读
1 #include 2 int main(){ 3 int i,t,j,n,x; 4 int start,end,temp,max,sum; 5 scanf("%d",&t); 6 for(i=0;i=max){15 ...
转载 2014-10-26 13:49:00
68阅读
2评论
题目大意:求使连续子序列的和最大的第一元素,最后一个元素位置,和子序列的和思路:动态规划的方法,主要是找到状态代码。状态转移方程:sum[i]=max(sum[i-1]+a[i],a[i]);
原创 2014-10-17 21:33:07
40阅读
  • 1
  • 2
  • 3
  • 4
  • 5