Submission #1222369

#TimeUsernameProblemLanguageResultExecution timeMemory
1222369__moin__Peru (RMI20_peru)C++20
0 / 100
1094 ms30220 KiB
#include <bits/stdc++.h> using namespace std; #include "peru.h" #define ll long long const ll p = 1e9+7; int solve(int n, int k, int* v){ vector<ll> dp(n); function<ll(int)> get = [&](int idx) { if (idx < 0) return 0ll; return dp[idx]; }; for (int i = 0; i < n; i++) { ll curmin = 1e18; int runmax = v[i]; for (int j = i-1; j >= i-k; j--) { curmin = min(curmin, ((ll)get(j) + (ll)runmax)); if (j < 0) break; runmax = max(runmax, v[j]); } dp[i] = curmin; } ll factor = 1; ll res = 0; for (int i = n-1; i >= 0; i--) { res += (dp[i]*factor) % p; res %= p; factor *= 23; factor %= p; } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...