#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |