Submission #1221880

#TimeUsernameProblemLanguageResultExecution timeMemory
1221880anonymous321Peru (RMI20_peru)C++20
0 / 100
1096 ms49220 KiB
#include "peru.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const ll M = 1e9 + 7; const ll INF = 2e9 + 1; int solve(int n, int k, int* v){ vector<ll> dp (n+1, INF); dp[0] = 0; ll sol = 0; vector<ll> ve (n, 1); for (int i = 1; i < n; i++) { ve[i] = (ve[i-1] * 23) % M; } for (int i = 0; i < n; i++) { ll cur = v[i]; for (int j = i; j >= max(0, i-k+1); j--) { cur = max(cur, (ll) v[j]); dp[i+1] = min(dp[i+1], dp[j] + cur); } sol += (ve[n - i - 1] * dp[i+1]) % M; sol %= M; } return sol; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...