Submission #15327

#TimeUsernameProblemLanguageResultExecution timeMemory
15327kyma123달리는 게임 (kriii3_E)C++98
0 / 70
56 ms5524 KiB
#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 = -1000000; for(int i=0;i<v.size();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]); 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...