Submission #848912

#TimeUsernameProblemLanguageResultExecution timeMemory
848912TahirAliyevPeru (RMI20_peru)C++17
0 / 100
1 ms344 KiB
#include "peru.h" #include <bits/stdc++.h> #define ll long long #define oo 1e16 using namespace std; const int MAX = 2002, MOD = 1e9 + 7; int arr[MAX]; ll dp[MAX]; int solve(int n, int k, int* v){ for(int i = 1; i <= n; i++){ dp[i] = oo; } for(int i = 0; i < n; i++){ arr[i + 1] = v[i]; } for(int i = 1; i <= n; i++){ int m = 0; for(int j = 1; j <= k; j++){ if(i - j < 0) break; m = max(arr[i - j + 1], m); dp[i] = min(dp[i - j] + m, dp[i]); } } ll ans = 0; ll p = 1; for(int i = n; i >= 1; i--){ ans += dp[i] * p % MOD; ans %= 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...