Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* b565 */
- /* AC (0ms, 92KB) */
- #include <cstdio>
- using namespace std;
- int arr[50];
- int n, Max, sum;
- int main()
- {
- for(~scanf("%d", &n))
- {
- for(int i = 0; i < n && scanf("%d", &sum); arr[i] = sum, i++);
- Max = sum = 0;
- for(int i = 0; i < n; i++)
- {
- sum += arr[i];
- if(sum < 0) sum = 0;
- Max = (sum > Max ? sum : Max);
- }
- printf("%d\n", Max);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement