結果

問題 No.1353 Limited Sequence
ユーザー 👑 PCTprobabilityPCTprobability
提出日時 2021-01-17 00:59:06
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 198 ms / 2,000 ms
コード長 1,598 bytes
コンパイル時間 2,168 ms
コンパイル使用メモリ 164,316 KB
実行使用メモリ 34,816 KB
最終ジャッジ日時 2024-05-06 10:25:59
合計ジャッジ時間 6,481 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 75 ms
16,384 KB
testcase_13 AC 83 ms
12,160 KB
testcase_14 AC 16 ms
11,648 KB
testcase_15 AC 51 ms
20,224 KB
testcase_16 AC 6 ms
5,632 KB
testcase_17 AC 10 ms
8,704 KB
testcase_18 AC 75 ms
16,512 KB
testcase_19 AC 118 ms
27,264 KB
testcase_20 AC 26 ms
10,752 KB
testcase_21 AC 7 ms
5,376 KB
testcase_22 AC 10 ms
7,296 KB
testcase_23 AC 77 ms
14,720 KB
testcase_24 AC 50 ms
10,752 KB
testcase_25 AC 104 ms
22,528 KB
testcase_26 AC 45 ms
12,160 KB
testcase_27 AC 25 ms
6,912 KB
testcase_28 AC 22 ms
13,056 KB
testcase_29 AC 16 ms
5,376 KB
testcase_30 AC 63 ms
9,600 KB
testcase_31 AC 37 ms
9,344 KB
testcase_32 AC 24 ms
15,232 KB
testcase_33 AC 8 ms
8,320 KB
testcase_34 AC 43 ms
21,376 KB
testcase_35 AC 12 ms
9,216 KB
testcase_36 AC 14 ms
9,984 KB
testcase_37 AC 198 ms
34,688 KB
testcase_38 AC 182 ms
34,688 KB
testcase_39 AC 186 ms
34,816 KB
testcase_40 AC 182 ms
34,688 KB
testcase_41 AC 186 ms
34,688 KB
testcase_42 AC 172 ms
34,688 KB
testcase_43 AC 189 ms
34,560 KB
testcase_44 AC 191 ms
34,816 KB
testcase_45 AC 180 ms
34,688 KB
testcase_46 AC 195 ms
34,688 KB
testcase_47 AC 66 ms
34,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define all(s) (s).begin(),(s).end()
#define vcin(n) for(ll i=0;i<ll(n.size());i++) cin>>n[i]
#define rever(vec) reverse(vec.begin(), vec.end())
#define sor(vec) sort(vec.begin(), vec.end())
#define fi first
#define se second
const ll mod = 998244353;
//const ll mod = 1000000007;
const ll inf = 2000000000000000000ll;
static const long double pi = 3.141592653589793;
template<class T,class U> void chmax(T& t,const U& u){if(t<u) t=u;}
template<class T,class U> void chmin(T& t,const U& u){if(t>u) t=u;}
ll modPow(ll a, ll n, ll mod) { ll ret = 1; ll p = a % mod; while (n) { if (n & 1) ret = ret * p % mod; p = p * p % mod; n >>= 1; } return ret; }
int main() {
  /* mod は 1e9+7 */
  ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
  cout<< fixed << setprecision(10);
  ll n,l,r;
  cin>>n>>l>>r;
  assert(2<=n&&n<=2000&&1<=l&&l<=r&&r<=2000);
  vector<ll> a(n);
  vcin(a);
  for(int i=0;i<n;i++){
      assert(1<=a[i]&&a[i]<=2000);
  }
  ll dp[r+1][n+1];
  ll sum[r+1];
  for(int i=0;i<=r;i++){
    for(int j=0;j<=n;j++){
      dp[i][j]=0;
    }
  }
  for(int i=0;i<=r;i++){
    sum[i]=0;
  }
  dp[0][0]=1;
  sum[0]=1;
  for(int i=0;i<=r;i++){
    for(int j=1;j<=n;j++){
      ll t=dp[i][j];
      for(int k=1;j*k<=i&&k<=a[j-1];k++){
        t+=sum[i-k*j]-dp[i-k*j][j];
        t%=mod;
        t+=mod;
        t%=mod;
      }
      t%=mod;
      dp[i][j]=t;
      sum[i]+=t;
      sum[i]%=mod;
    }
  }
  ll ans=0;
  for(int i=l;i<=r;i++){
    ans+=sum[i];
    ans%=mod;
  }
  cout<<ans<<endl;
}
0