# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
15229 |
2015-07-12T04:13:58 Z |
myungwoo |
달리는 게임 (kriii3_E) |
C++14 |
|
3 ms |
29064 KB |
#include <bits/stdc++.h>
using namespace std;
#define MAXN 1000006
typedef long long lld;
int N;
int A[MAXN];
lld D[MAXN], Nu[MAXN], S[MAXN];
int main()
{
scanf("%d", &N);
for (int i=1;i<=N;i++) scanf("%d", A+i);
for (int i=1;i<=N;i++) Nu[i] = Nu[i-1] + (lld)i * A[i], S[i] = S[i-1] + A[i];
lld ans = 0;
for (int i=1;i<=N;i++){
D[i] = 0;
for (int j=0;j<i;j++){
D[i] = max(D[i], D[j] - Nu[j] + S[j] * j - S[i] * j + Nu[i]);
}
ans = max(ans, D[i]);
}
printf("%lld\n", ans);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
29064 KB |
Output is correct |
2 |
Incorrect |
0 ms |
29064 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Halted |
0 ms |
0 KB |
- |