1 solutions

  • 0
    @ 2022-6-2 22:09:15
    #include <bits/stdc++.h>
    using namespace std;
    #define accelerate ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
    #define endl "\n";
    #define mod 1000000007
    #define ll long long
    #define PII pair<int,int>
    #define INF 0x3f3f3f3f
    const int N=1e5+10;
    int n,m,k,x,y,T;
    int a[N];
    int main(){
    	accelerate;
    	cin>>n;
    	for(int i=1;i<=n;i++){
    		cin>>a[i];
    	}
    	k=a[1];
    	for(int i=1;i<=n;i++){
    		m+=a[i];
    		if(m<=0) m=0;
    		else{
    			k=max(k,m);
    		}
    	}
    	cout<<k;
    	return 0;
    }
    
    • 1

    Information

    ID
    926
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    4
    Tags
    # Submissions
    54
    Accepted
    27
    Uploaded By