hdu 1003 最大连续子串
#include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #define TS printf("!!!\n") #define pb push_back //std::ios::sync_with_stdio(false); using namespace std; //priority_queue<int,vector<int>,greater<int>> que; const double EPS = 1.0e-8; typedef pair<int, int> pairint; typedef long long ll; typedef unsigned long long ull; const int maxn = 1e5 + 100; const int maxm = 300; //next_permutation priority_queue<int, vector<int>, greater<int>> que; int number[200005]; int dp[200005]; int main() { //freopen("in.txt", "r", stdin); int time ; cin >> time; while(time--) { int maxn=-1; dp[0]=0; int n; cin >> n; for(int i=1;i<=n;i++) { cin >>number[i]; dp[i]=dp[i-1]+number[i]; maxn=max(maxn,dp[i]); if(dp[i]<0) dp[i]=0; } cout<<maxn<<endl; } }