Submission #15375

#TimeUsernameProblemLanguageResultExecution timeMemory
15375tlwpdus달리는 게임 (kriii3_E)C++98
26 / 70
6 ms9060 KiB
#include<stdio.h> using namespace std; long long map[1010][1010]; long long sco[1010]; int n; void input() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%lld", &sco[i]); } } void process() { int i, j, k; long long maxi; for (j = 0; j < n; j++) { for (i = 0; i <= j+1; i++) { if (i == 0) { if (j == 0){ map[i][j] = 0; continue; } maxi = -1000000000000000000L; for (k = 0; k <= j; k++) { if (maxi < map[k][j - 1]) maxi = map[k][j - 1]; map[i][j] = maxi; } continue; } if (j == 0) map[i][j] = i*sco[j]; else { map[i][j] = map[i - 1][j - 1] + i*sco[j]; } } } maxi = -1000000000000000000L; for (i = 0; i <= n; i++) if (maxi < map[i][n - 1]) maxi = map[i][n - 1]; printf("%lld\n", maxi); } int main() { input(); process(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...