-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10211.cpp
More file actions
39 lines (34 loc) · 699 Bytes
/
10211.cpp
File metadata and controls
39 lines (34 loc) · 699 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vint;
const int INF = 0x3f3f3f3f; const int mINF = 0xc0c0c0c0;
const ll LINF = 0x3f3f3f3f3f3f3f3f; const ll mLINF = 0xc0c0c0c0c0c0c0c0;
int ans;
int T,N;
int arr[1001];
int dp[1001];
void sol() {
dp[1] = arr[1];
ans = dp[1];
for(int i=2;i<=N;++i) {
dp[i] = max(dp[i-1]+arr[i], arr[i]);
ans = dp[i] > ans ? dp[i] : ans;
}
cout << ans << '\n';
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> T;
while(T--) {
cin >> N;
memset(arr,0,sizeof(arr));
memset(dp, mINF,sizeof(dp));
for(int i=1;i<=N;++i) {
cin >> arr[i];
}
sol();
}
return 0;
}