# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
15476 |
2015-07-12T08:15:15 Z |
tonyjjw |
달리는 게임 (kriii3_E) |
C++14 |
|
1 ms |
1108 KB |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
using namespace std;
const int N = 1024;
int n;
long long inp[N], A[N], dp[N];
int main(void) {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%lld", &inp[i]);
}
A[n-1] = inp[n-1];
for (int i = n-2; i >= 0; i--)
A[i] = A[i+1] + inp[i];
dp[0] = max(inp[0], 0ll);
for (int j = 1; j < n; j++) {
dp[j] = dp[j-1];
long long sum = 0;
for (int i = j; i >= 0; i--) {
sum += (long long)(A[i] - A[j+1]);
//printf("sum: %lld\n", sum);
dp[j] = max(dp[j], dp[i-1] + sum);
}
//printf("at %d: %lld\n", j, dp[j]);
}
long long ans = 0;
for (int i = 0; i < n; i++)
ans = max(ans, dp[i]);
printf("%lld\n", ans);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1108 KB |
Output is correct |
2 |
Correct |
1 ms |
1108 KB |
Output is correct |
3 |
Correct |
0 ms |
1108 KB |
Output is correct |
4 |
Correct |
0 ms |
1108 KB |
Output is correct |
5 |
Correct |
1 ms |
1108 KB |
Output is correct |
6 |
Correct |
1 ms |
1108 KB |
Output is correct |
7 |
Correct |
1 ms |
1108 KB |
Output is correct |
8 |
Correct |
1 ms |
1108 KB |
Output is correct |
9 |
Correct |
0 ms |
1108 KB |
Output is correct |
10 |
Correct |
0 ms |
1108 KB |
Output is correct |
11 |
Correct |
1 ms |
1108 KB |
Output is correct |
12 |
Correct |
0 ms |
1108 KB |
Output is correct |
13 |
Correct |
0 ms |
1108 KB |
Output is correct |
14 |
Correct |
0 ms |
1108 KB |
Output is correct |
15 |
Correct |
0 ms |
1108 KB |
Output is correct |
16 |
Correct |
0 ms |
1108 KB |
Output is correct |
17 |
Correct |
0 ms |
1108 KB |
Output is correct |
18 |
Correct |
0 ms |
1108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
1104 KB |
SIGSEGV Segmentation fault |
2 |
Halted |
0 ms |
0 KB |
- |