# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
15379 |
2015-07-12T06:56:00 Z |
kyma123 |
달리는 게임 (kriii3_E) |
C++ |
|
2 ms |
17220 KB |
#include <stdio.h>
#include <vector>
using namespace std;
long long int dp[2][1001234];
long long int maxv(long long int v[], int n){
long long int M = v[0];
for(int i=1;i<n;i++)
M = (M>v[i]) ? M : v[i];
return M;
}
int main(){
int n, now, prev;
scanf("%d", &n);
vector<int> num;
num.resize(n);
for(int i=0;i<n;i++)
scanf("%d", &num[i]);
dp[0][0] = 0;
dp[0][1] = num[0];
for(int z=1;z<n;z++){
now = z%2;
prev = (z-1)%2;
dp[now][0] = maxv(dp[prev], z+1);
for(int i=1;i<z+2;i++)
dp[now][i] = dp[prev][i-1] + i*num[z];
}
printf("%lld\n", maxv(dp[(n-1)%2], n));
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
17220 KB |
Output is correct |
2 |
Correct |
0 ms |
17220 KB |
Output is correct |
3 |
Incorrect |
0 ms |
17220 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Halted |
0 ms |
0 KB |
- |