hit oj 1760 The jackpot (最大子段和)

本文探讨如何通过编程辅助制定赌博策略以实现快速致富,包括识别盈利模式、设计赢赢策略。通过输入序列的赌注结果,输出可能的最大赢利或警告连续亏损。

As Manuel wants to get rich fast and without too much work, he decided to make a career in gambling. Initially, he plans to study the gains and losses of players, so that, he can identify patterns of consecutive wins and elaborate a win-win strategy. But Manuel, as smart as he thinks he is, does not know how to program computers. So he hired you to write programs that will assist him in elaborating his strategy.

Your first task is to write a program that identifies the maximum possible gain out of a sequence of bets. A bet is an amount of money and is either winning (and this is recorded as a positive value), or losing (and this is recorded as a negative value).

Input

The input set consists of a positive number N <= 10000 , that gives the length of the sequence, followed by N integers. Each bet is an integer greater than 0 and less than 1000.

The input is terminated with N = 0.

Output

For each given input set, the output will echo a line with the corresponding solution. If the sequence shows no possibility to win money, then the output is the message "Losing streak."

Sample Input

5
12 -4 -10 4 9
3
-2 -1 -2
0

Sample Output

The maximum winning streak is 13.Losing streak.

最大字段和问题,下面的代码用dp做:

用s[i]表示以a[i]结尾的最大字段,状态转移方程:s[i]=max{0,s[i-1]}+a[i];

#include<stdio.h>
#include<string.h>
#include <limits.h>
int main()
{
    int n;
    while(scanf("%d",&n),n)
    {
        int i,j;
        int a[n+5];
        int s[n+5];
        memset(s,0,sizeof(s));
        for(i=1;i<=n;i++)scanf("%d",&a[i]);
        a[0]=0;
        s[0]=0;
        int m=0;
        for(i=1;i<=n;i++)
        {
            if(s[i-1]>0)
            s[i]=s[i-1]+a[i];
            else s[i]=a[i];
            if(m<s[i])m=s[i];
        }
        if(m>0)
        printf("The maximum winning streak is %d.\n",m);
        else printf("Losing streak.\n");
    }
}
 




农业作物成熟度实例分割数据集 一、基础信息 • 数据集名称:农业作物成熟度实例分割数据集 • 图片数量: 训练集:563张图片 验证集:161张图片 测试集:80张图片 总计:804张图片 • 训练集:563张图片 • 验证集:161张图片 • 测试集:80张图片 • 总计:804张图片 • 分类类别: bfullyripened: b类作物完全成熟状态 bgreen: b类作物绿色未成熟状态 bhalfripened: b类作物半成熟状态 lfullyripened: l类作物完全成熟状态 lgreen: l类作物绿色未成熟状态 lhalfripened: l类作物半成熟状态 • bfullyripened: b类作物完全成熟状态 • bgreen: b类作物绿色未成熟状态 • bhalfripened: b类作物半成熟状态 • lfullyripened: l类作物完全成熟状态 • lgreen: l类作物绿色未成熟状态 • lhalfripened: l类作物半成熟状态 • 标注格式:YOLO格式,包含实例分割多边形点标注,适用于实例分割任务。 • 数据格式:图片来源于农业图像数据库,细节清晰,适用于模型训练。 二、适用场景 • 农业AI监测系统开发:数据集支持实例分割任务,帮助构建能够自动识别作物部分并分类成熟度的AI模型,辅助农民进行精准农业管理。 • 精准农业应用研发:集成至农业智能平台,提供实时作物状态识别功能,优化灌溉、施肥收获时间。 • 学术研究与创新:支持农业科学与人工智能交叉领域的研究,助力发表高水平农业AI论文。 • 农业教育与培训:数据集可用于农业院校或培训机构,作为学生学习作物识别成熟度评估的重要资源。 三、数据集优势 • 精准标注与多样性:每张图片均经过精确标注,确保实例分割边界准确,类别分类正确。涵盖两种作物类型(bl)三种成熟度状态(完全成熟、绿色未成熟、半成熟),具有高度多样性,提升模型泛化能力。 • 任务适配性强:标注兼容主流深度学习框架(如YOLO等),可直接加载使用,支持实例分割任务,并可扩展到其他计算机视觉任务。 • 农业价值突出:专注于作物成熟度检测,为智能农业、自动化收获作物健康监测提供关键数据支持,具有重要的实际应用价值。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值