# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
15343 |
2015-07-12T06:22:05 Z |
kyma123 |
달리는 게임 (kriii3_E) |
C++ |
|
280 ms |
524288 KB |
#include <stdio.h>
#include <vector>
using namespace std;
vector<vector<long long int> > dp;
long long int maxv(vector<long long int> &v){
long long int M = v[0];
int n = v.size();
for(int i=1;i<n;i++)
M = (M>v[i]) ? M : v[i];
return M;
}
int main(){
int n;
scanf("%d", &n);
vector<int> num;
num.resize(n);
for(int i=0;i<n;i++)
scanf("%d", &num[i]);
dp.resize(n);
dp[0].resize(2);
dp[0][0] = 0;
dp[0][1] = num[0];
for(int z=1;z<n;z++){
dp[z].resize(z+2);
dp[z][0] = maxv(dp[z-1]);
for(int i=1;i<z+2;i++)
dp[z][i] = dp[z-1][i-1] + i*num[z];
}
/*
for(int z=0;z<n;z++){
for(int i=0;i<z+2;i++)
printf("%4lld", dp[z][i]);
printf("\n");
}
*/
printf("%lld\n", maxv(dp[n-1]));
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
5452 KB |
Output is correct |
2 |
Correct |
0 ms |
5452 KB |
Output is correct |
3 |
Correct |
0 ms |
5452 KB |
Output is correct |
4 |
Correct |
0 ms |
5452 KB |
Output is correct |
5 |
Correct |
0 ms |
5452 KB |
Output is correct |
6 |
Correct |
4 ms |
5452 KB |
Output is correct |
7 |
Correct |
0 ms |
5452 KB |
Output is correct |
8 |
Correct |
0 ms |
5452 KB |
Output is correct |
9 |
Correct |
0 ms |
5452 KB |
Output is correct |
10 |
Correct |
0 ms |
5452 KB |
Output is correct |
11 |
Correct |
4 ms |
5452 KB |
Output is correct |
12 |
Correct |
0 ms |
5452 KB |
Output is correct |
13 |
Correct |
0 ms |
5452 KB |
Output is correct |
14 |
Correct |
0 ms |
5452 KB |
Output is correct |
15 |
Correct |
0 ms |
5452 KB |
Output is correct |
16 |
Correct |
0 ms |
5452 KB |
Output is correct |
17 |
Correct |
0 ms |
5452 KB |
Output is correct |
18 |
Correct |
0 ms |
5452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Memory limit exceeded |
280 ms |
524288 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |