# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
15257 |
2015-07-12T04:44:44 Z |
tonyjjw |
달리는 게임 (kriii3_E) |
C++14 |
|
0 ms |
9280 KB |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
using namespace std;
const int N = 1024;
const long long INF = 1000ll * 1000ll * 1000ll * 1000ll * 1000ll;
int n, a[N];
long long dp[N][N];
int main(void) {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
}
for (int i = 0; i <= n; i++)
for (int j = 0; j <= n; j++)
dp[i][j] = -INF;
dp[0][0] = 0;
for (int i = 1; i <= n; i++) {
dp[i][0] = dp[i-1][0];
for (int j = 1; j <= i; j++) {
dp[i][j] = max(dp[i-1][j], dp[i-1][j-1] + (long long)j * a[i]);
}
}
long long ans = 0;
for (int j = 1; j <= n; j++) {
ans = max(ans, dp[n][j]);
}
printf("%lld\n", ans);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
9280 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Halted |
0 ms |
0 KB |
- |