結果

問題 No.2378 Cards and Subsequences
ユーザー MagentorMagentor
提出日時 2023-07-01 11:35:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,339 bytes
コンパイル時間 4,490 ms
コンパイル使用メモリ 262,236 KB
実行使用メモリ 66,460 KB
最終ジャッジ日時 2023-09-28 21:41:58
合計ジャッジ時間 7,927 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
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 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 83 ms
66,148 KB
testcase_32 AC 61 ms
66,156 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define REP(i, n) for (long long i = 1; i < (long long)(n); i++)
typedef long long ll;
using mint = modint;
void mod(ll &a){
	a %= 998244353;
	return;
}
int main() {
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> s(n), a(m), b(m);
    rep(i, n) {
        cin >> s[i];
        s[i]--;
    }
    rep(i, m) { cin >> a[i]; }
    rep(i, m) { cin >> b[i]; }
    vector<vector<ll>> dp(n + 1, vector<ll>(k + 1, 0));
    dp[0][0] = 1;
    vector<vector<ll>> cum(n + 2, vector<ll>(k + 1, 0));
    cum[1][0] = 1;
    vector<ll> idx(m, 0);
    rep(i, n) {
        rep(j, k + 1) {
            if (0 <= j - a[s[i]]) {
                dp[i + 1][j] +=
                    cum[i + 1][j - a[s[i]]] - cum[idx[s[i]]][j - a[s[i]]];
                mod(dp[i+1][j]);    
            }
            if (0 <= j - b[s[i]]) {
                dp[i + 1][j] +=
                    cum[i + 1][j - b[s[i]]] - cum[idx[s[i]]][j - b[s[i]]];
                mod(dp[i+1][j]);    
            }
            cum[i + 2][j] = cum[i + 1][j] + dp[i + 1][j];
            mod(dp[i+1][j]);
        }
        idx[s[i]] = i + 1;
    }
    ll ans = 0;
    rep(i, n) { ans += dp[i + 1][k]; }
    
    cout << ans << endl;
}
0