1 solutions
-
0
C++ :
#include <iostream> #include <cstdio> #include <string> #include <algorithm> using namespace std; long long dp[110]; int main() { //freopen("in.txt", "r", stdin); int T, n; while (cin>>T) { while (T--) { cin>>n; dp[0] = 0; long long ans = 0; for (int i=1; i<=n; i++) { long long temp; cin>>temp; dp[i] = max(dp[i-1]+temp, temp); ans = max(ans, dp[i]); } cout<<ans<<endl; } } return 0; }
- 1
Information
- ID
- 16476
- Time
- 5000ms
- Memory
- 64MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By