Submission #1057356

#TimeUsernameProblemLanguageResultExecution timeMemory
1057356TimDeePeru (RMI20_peru)C++17
18 / 100
237 ms13412 KiB
#include "peru.h" #include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("popcnt,avx2") #define forn(i,n) for(int i=0; i<(n); ++i) using ll = long long; const int N=2005; ll dp[N]; int solve(int n, int k, int* v){ const int mod = 1e9+7; dp[0]=0; forn(i,n) { int mx=0; dp[i+1]=1e18; for(int j=i; j>=max(i+1-k,0); --j) { mx=max(mx,v[j]); dp[i+1]=min(dp[i+1],dp[j]+mx); } } ll ans=0; ll p=1; for(int i=n; i>0; --i) { dp[i]%=mod; ans=(ans+p*dp[i])%mod; p=(23*p)%mod; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...