数据结构MOOC
PTA习题
01-复杂度2 Maximum Subsequence Sum

#include <iostream>
using namespace std;
const int M = 100005;
int a[M];
int main()
{
int k;
cin >> k;
int f = 1;
for (int i = 0; i < k; i++)
{
cin >> a[i];
if (a[i] >= 0)//如果出现大于0则进行在线处理
f = 0;
}
if (f)
{ //全都小于0
cout << "0" << ' ' << a[0] << ' ' << a[k - 1];
return 0;
}
int s = 0, ma = -1, l = 0, j = 0, r;
for (int i = 0; i < k; i++)
{
s += a[i];
if (s > ma)
{ //更新答案
ma = s;
r = a[i];
l = a[j];
}
if (s < 0)
{
s = 0;
j = i + 1; //因为扔掉了左边,所以答案数组的左指针一定大于i
}
}
cout << ma << ' ' << l << ' ' << r;
return 0;
}



![[论文笔记]大模型微调数据配比策略](https://i-blog.csdnimg.cn/direct/06020c4d79d44c4081b8b5e79f38f889.png)











![[数据集][目标检测]轮胎缺陷检测数据集VOC+YOLO格式2154张4类别](https://i-blog.csdnimg.cn/direct/5aca09e6aa35438e8bbaad0f14eee84e.png)



