# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
858848 |
2023-10-09T09:13:28 Z |
alexdumitru |
Peru (RMI20_peru) |
C++14 |
|
1 ms |
344 KB |
#include <bits/stdc++.h>
using namespace std;
int getAns(int dp[], int n)
{
int mul = 1;
int ans = 0;
const int MOD = 1e9 + 7;
for(int i = n - 1; i >= 0; i--)
{
ans = (1LL * ans + 1LL * dp[i] * mul) % MOD;
mul = (1LL * mul * 23) % MOD;
}
return ans;
}
int solve(int n, int k, int *s)
{
int dp[n + 2];
int Max = 0;
for(int i = 0; i < k; i++)
{
if(s[i] > Max)
Max = s[i];
dp[i] = Max;
}
for(int i = k; i < n; i++)
{
int currMax = s[i];
dp[i] = INT_MAX;
for(int j = i - 1; j >= i - k; j--)
{
if(dp[i] > dp[j] + currMax)
dp[i] = dp[j] + currMax;
if(s[j] > currMax)
currMax = s[j];
}
}
return getAns(dp, n);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |