# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
15220 |
2015-07-12T04:05:51 Z |
gs14004 |
달리는 게임 (kriii3_E) |
C++14 |
|
1000 ms |
32332 KB |
#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) - s2[i-1] + (j ? s2[j-1] : 0));
}
}
printf("%lld",dp[n]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
32332 KB |
Output is correct |
2 |
Correct |
0 ms |
32332 KB |
Output is correct |
3 |
Correct |
0 ms |
32332 KB |
Output is correct |
4 |
Correct |
2 ms |
32332 KB |
Output is correct |
5 |
Correct |
0 ms |
32332 KB |
Output is correct |
6 |
Correct |
0 ms |
32332 KB |
Output is correct |
7 |
Correct |
2 ms |
32332 KB |
Output is correct |
8 |
Correct |
0 ms |
32332 KB |
Output is correct |
9 |
Correct |
0 ms |
32332 KB |
Output is correct |
10 |
Correct |
0 ms |
32332 KB |
Output is correct |
11 |
Correct |
2 ms |
32332 KB |
Output is correct |
12 |
Correct |
2 ms |
32332 KB |
Output is correct |
13 |
Correct |
2 ms |
32332 KB |
Output is correct |
14 |
Correct |
2 ms |
32332 KB |
Output is correct |
15 |
Correct |
0 ms |
32332 KB |
Output is correct |
16 |
Correct |
0 ms |
32332 KB |
Output is correct |
17 |
Correct |
0 ms |
32332 KB |
Output is correct |
18 |
Correct |
0 ms |
32332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1000 ms |
32328 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |