이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long lint;
int n;
lint dp[1000005];
lint a[1000005];
lint s1[1000005];
lint s2[1000005];
int main(){
scanf("%d",&n);
for(int i=1; i<=n; i++){
scanf("%lld",&a[i]);
s1[i] = s1[i-1] + a[i];
s2[i] = s2[i-1] + s1[i];
}
for(int i=1; i<=n; i++){
dp[i] = dp[i-1];
for(int j=0; j<i; j++){
dp[i] = max(dp[i], dp[j] + s1[i] * (i - j + 1) + s2[j] - s2[i]);
}
}
printf("%lld",dp[n]);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |