思路: 分两种情况讨论. 实现: #include <bits/stdc++.h> using namespace std; typedef long long ll; ; ll sum[N]; int main() { int n, x; while (cin >> n) { ll maxn = , minn = , ans = , mins = ; ; i <= n; i++) { cin >> x; sum[i] = sum[i - ] + x; ans =…
题目链接:51nod 1050 循环数组最大子段和 #include<stdio.h> #include<algorithm> using namespace std; ; long long a[N]; int main(){ int n, i; ; scanf("%d", &n); ; i <= n; ++i){ scanf("%I64d", &a[i]); sum += a[i]; } ma_ed = a[]; a…
题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1050 这道题的最大子段和有两种可能,一种是常规的子段和,另一种是从结尾到开头的一个子段.常规做是一种可能,另一种带循环的则可以认为是序列中间有一段最小子段和,把这段最小子段和去掉,剩下的可能就是最大子段和了. #include <bits/stdc++.h> using namespace std; typedef long long LL; * ; int…