Submission #474502

#TimeUsernameProblemLanguageResultExecution timeMemory
474502AlexandruabcdePeru (RMI20_peru)C++14
18 / 100
806 ms5212 KiB
#include "peru.h" #include <iostream> using namespace std; constexpr int NMAX = 2500005; constexpr int MOD = 1e9 + 7; typedef long long LL; LL dp[NMAX]; int ans = 0; int solve(int n, int k, int* v){ for (int i = 0; i < n; ++ i ) { int Max_Effort = v[i]; dp[i] = 100000000000000000; for (int j = i; j > max(0, i-k+1); -- j ) { Max_Effort = max(Max_Effort, v[j]); dp[i] = min(dp[i], dp[j-1] + 1LL * Max_Effort); } Max_Effort = max(Max_Effort, v[max(0, i-k+1)]); if (i < k) dp[i] = min(dp[i], 1LL * Max_Effort); else dp[i] = min(dp[i], dp[i-k] + 1LL * Max_Effort); } for (int i = 0; i < n; ++ i ) { ans = (23LL * ans + dp[i]%MOD) % MOD; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...