#include <stdio.h>

int num[100001];
int dp[100001];

int max(int a,int b) {
    return a>b? a:b;
}
int bottom_up(int n) {
    //초기화 기저
    dp[0]=num[0];
    int max_n=dp[0];

    for(int i=0; i<n;i++) {
        dp[i]=max(dp[i-1]+num[i],num[i]);

        if(max_n<dp[i]) max_n=dp[i];
    }
    return max_n;
}
int main() {
    int t;
    
    scanf("%d",&t);
    for(int i=0; i<t; i++) {
        scanf("%d",&num[i]);
    }
    printf("%d",bottom_up(t));
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: