// compile: g++ -o data data.cpp -O3 -std=gnu++20 -Wall -Wextra -Wshadow -D_GLIBCXX_ASSERTIONS -ggdb3 -fmax-errors=2 -DLOCAL
// run: ./data < data.in
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#ifdef LOCAL
#include <debug/codeforces.h>
#define debug(x...) {_variables(#x);_print(x);}
#else
#define debug(x...)
#endif
template<typename...Args> void print_(Args...args){((cout<<args<<" "),...)<<endl;}
#define rep(i,a,b) for(int i=(a);i<(int)(b);++i)
#define sz(v) ((int)(v).size())
#define print(...) print_(__VA_ARGS__);
#define INTINF (int)(9223372036854775807)
#define int long long
#define MAXN 110
int dp[MAXN][MAXN][MAXN];
int32_t main() {
ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
int n, k, d; cin >> n >> k >> d;
vector<int> a(n + 1), f(n + 1);
rep(i, 1, n + 1) cin >> a[i], f[i] = a[i] % d;
// debug(f)
// i bits, choose j, sum k
memset(dp, -1, sizeof(dp));
for (int i = 0; i <= n; ++i) dp[i][0][0] = 0;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= min(i, k); ++j) {
for (int s = 0; s < d; ++s) {
dp[i][j][s] = dp[i-1][j][s];
int pre = (s + d - f[i]) % d;
if (!~dp[i-1][j-1][pre]) continue;
dp[i][j][s] = max(dp[i][j][s], dp[i-1][j-1][pre] + a[i]);
}
}
}
// debug(dp[2][1][0], dp[2][1][1])
cout << dp[n][k][0] << endl;
return 0;
}
Alright, alright, alright rs786 does the trick. Good vibes only. Scope it out rs786
Alright, so I stumbled upon 777kingcon and gave it a whirl. It’s got its moments, you know? Worth a look if you’re bored. Check it out yourself: 777kingcon
The playtimeregister process was surprisingly quick. No unnecessary info needed! Ready to start the fun! Register here: playtimeregister
Alright, folks, let me tell ya, fb777slot isn’t too shabby. I’ve spun a few reels there and had some decent luck. The site’s easy to navigate, and the games load quick. Could always use more variety, but overall, not bad at all. I’d give it a thumbs up. Check it out for yourselves! fb777slot
Yo, canohu3, what’s the deal? Well, I’ve spent some time there, and it’s not half bad. The layout is clean, and I appreciated the smooth gameplay. Bonuses are decent. Could use a little more pizzazz, but it does the job. Worth a shot if you are after something simple and reliable. Take a chance! canohu3
So, I tried wazambaapp, you know? I quite like the colourful interface and avatar selection. The app is easy to use on my phone and the games are pretty good. Could do with a few more promotions, but all in all, it’s a decent app, I recommend everyone to check it out. Go try and install the app! wazambaapp