結果

問題 No.2378 Cards and Subsequences
ユーザー pointNpointN
提出日時 2023-07-13 14:25:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 1,657 bytes
コンパイル時間 3,450 ms
コンパイル使用メモリ 191,432 KB
実行使用メモリ 66,160 KB
最終ジャッジ日時 2023-10-13 03:22:10
合計ジャッジ時間 8,805 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 3 ms
4,356 KB
testcase_04 AC 4 ms
4,888 KB
testcase_05 AC 3 ms
4,364 KB
testcase_06 AC 9 ms
9,252 KB
testcase_07 AC 11 ms
11,272 KB
testcase_08 AC 13 ms
12,256 KB
testcase_09 AC 15 ms
14,184 KB
testcase_10 AC 6 ms
6,000 KB
testcase_11 AC 72 ms
66,044 KB
testcase_12 AC 72 ms
66,060 KB
testcase_13 AC 72 ms
65,844 KB
testcase_14 AC 72 ms
65,924 KB
testcase_15 AC 73 ms
66,064 KB
testcase_16 AC 73 ms
65,964 KB
testcase_17 AC 72 ms
66,096 KB
testcase_18 AC 72 ms
65,932 KB
testcase_19 AC 73 ms
65,892 KB
testcase_20 AC 74 ms
65,840 KB
testcase_21 AC 73 ms
65,892 KB
testcase_22 AC 74 ms
65,984 KB
testcase_23 AC 74 ms
65,928 KB
testcase_24 AC 74 ms
66,000 KB
testcase_25 AC 73 ms
65,892 KB
testcase_26 AC 74 ms
66,032 KB
testcase_27 AC 74 ms
65,848 KB
testcase_28 AC 75 ms
65,916 KB
testcase_29 AC 75 ms
65,928 KB
testcase_30 AC 75 ms
66,160 KB
testcase_31 AC 74 ms
65,880 KB
testcase_32 AC 73 ms
65,892 KB
testcase_33 AC 74 ms
65,924 KB
testcase_34 AC 74 ms
65,948 KB
testcase_35 AC 74 ms
65,892 KB
testcase_36 AC 74 ms
65,928 KB
testcase_37 AC 7 ms
6,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#include <atcoder/all>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

const ll mod = 998244353;

int main(){
  ll N,M,K; cin >> N >> M >> K;
  vector<ll> S(N);
  rep(i,N) cin >> S[i];
  rep(i,N) S[i]--;
  vector<ll> A(M),B(M);
  rep(i,M) cin >> A[i];
  rep(i,M) cin >> B[i];
  vector<vector<ll>> dp(N+1,vector<ll>(K+1,0));
  vector<vector<ll>> dps(N+2,vector<ll>(K+1,0));
  dps[1][0] = 1;
  dp[0][0] = 1;
  for(int i=1;i<=N;i++){
    int s = S[i-1];
    vector<ll> V = dps[i];
    int p = i-1;
    while(p-1 >= 0){
      if(S[p-1]!=s) p--;
      else break;
    }
    rep(j,K+1) V[j] = ( V[j] - dps[p][j] + mod ) % mod;
    rep(j,K+1){
      if(j-A[s] >= 0) dp[i][j] += V[j-A[s]];
      if(j-B[s] >= 0) dp[i][j] += V[j-B[s]];
      dp[i][j] %= mod;
    }
    rep(j,K+1){
      dps[i+1][j] = (dps[i][j] + dp[i][j]) % mod;
    }
  }
  ll ans = 0;
  rep(i,N+1) ans += dp[i][K];
  cout << ans % mod << '\n';
  return 0;
};
0