Submission #639278

#TimeUsernameProblemLanguageResultExecution timeMemory
639278bluePeru (RMI20_peru)C++17
0 / 100
1 ms340 KiB
#include "peru.h" #include <bits/stdc++.h> using namespace std; using vi = vector<int>; using pii = pair<int, int>; using ll = long long; using vll = vector<ll>; const ll inf = 1'000'000'000'000'000'000LL; const ll mod = 1'000'000'007; ll mul(ll a, ll b) { return (a*b)%mod; } ll ad(ll a, ll b) { return (a+b)%mod; } int solve(int N, int K, int* v) { vll dp(1+N, inf); dp[0] = 0; for(int i = 1; i <= N; i++) { int rmx = 0; for(int j = i-1; j >= i-K && j >= 0; j--) { rmx = max(rmx, v[j+1 - 1]); dp[i] = min(dp[i], dp[j] + rmx); } // cerr << i << " : " << dp[i] << '\n'; } ll res = 0; ll coeff = 1; for(int i = N; i >= 1; i--) { res = ad(res, mul(dp[i], coeff)); coeff = mul(coeff, 23); } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...