Submission #872599

#TimeUsernameProblemLanguageResultExecution timeMemory
87259912345678Peru (RMI20_peru)C++17
0 / 100
1 ms348 KiB
#include "peru.h" #include <bits/stdc++.h> using namespace std; const int mod=1e9+7; int solve(int n, int k, int* v){ vector<long long> dp(n+1), p(n+1); long long res=0; p[0]=1; for (int i=1; i<=n; i++) p[i]=(p[i-1]*23)%mod; for (int i=1; i<=n; i++) { int mx=0; dp[i]=LLONG_MAX; for (int j=i; j>=max(i-k+1, 1); j--) { mx=max(mx, v[j-1]); dp[i]=min(dp[i], dp[j-1]+mx); } res=(res+p[n-i]*dp[i])%mod; //cout<<i<<' '<<dp[i]<<'\n'; } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...