# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
854687 |
2023-09-28T14:16:12 Z |
tibinyte |
Peru (RMI20_peru) |
C++14 |
|
0 ms |
0 KB |
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int inf = 1e16;
const int mod = 1e9 + 7;
struct Mint
{
int val;
Mint(int x = 0)
{
val = x % mod;
}
Mint(long long x)
{
val = x % mod;
}
Mint operator+(Mint oth)
{
return val + oth.val;
}
Mint operator-(Mint oth)
{
return val - oth.val + mod;
}
Mint operator*(Mint oth)
{
return 1ll * val * oth.val;
}
};
Mint powmod(int a, int b)
{
if (b == 0)
{
return 1;
}
if (b % 2 == 1)
{
return powmod(a, b - 1) * a;
}
Mint P = powmod(a, b / 2);
return P * P;
}
int solve(int n, int k, int *S)
{
vector<int> a(n + 1);
for (int i = 1; i <= n; ++i)
{
a[i] = S[i - 1];
}
Mint ans = 0;
vector<int> dp(n + 1, inf);
dp[0] = 0;
for (int i = 1; i <= n; ++i)
{
int maxi = 0;
for (int j = i; j >= max(1ll, i - k + 1); --j)
{
maxi = max(maxi, a[j]);
dp[i] = min(dp[i], dp[j - 1] + maxi);
}
ans = ans + powmod(23, n - i) * dp[i];
}
return ans.val;
}
Compilation message
peru.cpp:13:5: error: 'Mint::Mint(long long int)' cannot be overloaded with 'Mint::Mint(long long int)'
13 | Mint(long long x)
| ^~~~
peru.cpp:9:5: note: previous declaration 'Mint::Mint(long long int)'
9 | Mint(int x = 0)
| ^~~~