Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- int main(){
- ll n;
- cin>>n;
- ll arr[n];
- ll sum=0, maxsum=-100000000;
- ll rez=-10000000;
- for(int i=0; i<n;i++){
- cin>>arr[i];
- }
- for(int i=0;i<n;i++){
- sum+=arr[i];
- maxsum=max(maxsum+arr[i], arr[i]);
- if(maxsum>rez){
- rez=maxsum;
- }
- }
- cout<<rez;
- return 0;
- }
Add Comment
Please, Sign In to add comment