結果

問題 No.2378 Cards and Subsequences
ユーザー KowerKoint2010KowerKoint2010
提出日時 2023-06-30 08:25:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,113 bytes
コンパイル時間 2,296 ms
コンパイル使用メモリ 207,428 KB
実行使用メモリ 34,708 KB
最終ジャッジ日時 2023-09-28 21:41:00
合計ジャッジ時間 7,352 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 135 ms
34,404 KB
testcase_22 AC 137 ms
34,400 KB
testcase_23 AC 136 ms
34,708 KB
testcase_24 AC 137 ms
34,444 KB
testcase_25 AC 136 ms
34,416 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 145 ms
34,444 KB
testcase_32 AC 104 ms
34,364 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    constexpr ll MOD = 998244353;
    int n, m, k; cin >> n >> m >> k;
    vector<int> s(n), a(m), b(m);
    for(int i = 0; i < n; i++) {
        cin >> s[i];
        s[i]--;
    }
    sort(s.begin(), s.end());
    for(int i = 0; i < m; i++) cin >> a[i];
    for(int i = 0; i < m; i++) cin >> b[i];
    vector<vector<ll>> dp(k+1, vector<ll>(n+1)); // 総和がi、[0, j)を使う
    dp[0][0] = 1;
    vector<int> last_appeared(m, -1);
    for(int i = 0; i < n; i++) {
        for(int j = 0; j <= k; j++) dp[j][i+1] = dp[j][i];
        for(int j = 0; j <= k; j++) {
            for(int c : {a[s[i]], b[s[i]]}) {
                if(j+c <= k) {
                    dp[j+c][i+1] += dp[j][i];
                    if(last_appeared[s[i]] != -1) {
                        dp[j+c][i+1] -= dp[j][last_appeared[s[i]]];
                    }
                    dp[j+c][i+1] %= MOD;
                }
            }
        }
        last_appeared[s[i]] = i;
    }
    ll ans = dp[k][n];
    if(ans < 0) ans += MOD;
    cout << ans << endl;
}
0