AtCoder abc281 D
// 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;
}

Comments

  1. 5 months ago
    2025-12-06 2:46:12

    Alright, alright, alright rs786 does the trick. Good vibes only. Scope it out rs786

  2. 5 months ago
    2025-12-19 14:00:31

    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

  3. 4 months ago
    2025-12-29 6:28:48

    The playtimeregister process was surprisingly quick. No unnecessary info needed! Ready to start the fun! Register here: playtimeregister

  4. 4 weeks ago
    2026-4-10 13:39:46

    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

  5. 4 weeks ago
    2026-4-10 13:40:01

    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

  6. 4 weeks ago
    2026-4-10 13:40:17

    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

Send Comment Edit Comment


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
Previous
Next