Submission #15411

#TimeUsernameProblemLanguageResultExecution timeMemory
15411yukariko달리는 게임 (kriii3_E)C++98
0 / 70
6 ms9552 KiB
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; long long a[1001]; long long dp[1001][1001]; int N; long long solve(int pos, int cnt) { if(pos == N) return 0; long long &ret = dp[pos][cnt]; if(ret != -1) return ret; ret = 0; ret = max(ret, solve(pos+1, cnt)); ret = max(ret, a[pos] * (cnt+1) + solve(pos+1, cnt+1)); return ret; } int main() { memset(dp,-1,sizeof(dp)); cin >> N; for(int i=0; i < N; i++) cin >> a[i]; cout << solve(0, 0); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...