#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
long long a[1001];
long long dp[1001][1001];
int N;
long long solve(int pos, int cnt)
{
if(pos == N)
return 0;
long long &ret = dp[pos][cnt];
if(ret != -1)
return ret;
ret = 0;
ret = max(ret, solve(pos+1, cnt));
ret = max(ret, a[pos] * (cnt+1) + solve(pos+1, cnt+1));
return ret;
}
int main()
{
memset(dp,-1,sizeof(dp));
cin >> N;
for(int i=0; i < N; i++)
cin >> a[i];
cout << solve(0, 0);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
9552 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Halted |
0 ms |
0 KB |
- |