結果

問題 No.1353 Limited Sequence
ユーザー 👑 PCTprobabilityPCTprobability
提出日時 2021-01-14 19:07:14
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 1,489 bytes
コンパイル時間 2,601 ms
コンパイル使用メモリ 165,720 KB
実行使用メモリ 34,736 KB
最終ジャッジ日時 2024-05-03 12:04:42
合計ジャッジ時間 6,944 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 2 ms
6,812 KB
testcase_03 AC 2 ms
6,816 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 79 ms
16,452 KB
testcase_13 AC 100 ms
12,152 KB
testcase_14 AC 17 ms
11,640 KB
testcase_15 AC 53 ms
20,224 KB
testcase_16 AC 7 ms
6,944 KB
testcase_17 AC 9 ms
8,740 KB
testcase_18 AC 86 ms
16,360 KB
testcase_19 AC 115 ms
27,208 KB
testcase_20 AC 27 ms
10,776 KB
testcase_21 AC 8 ms
6,944 KB
testcase_22 AC 10 ms
7,320 KB
testcase_23 AC 77 ms
14,820 KB
testcase_24 AC 52 ms
10,720 KB
testcase_25 AC 100 ms
22,508 KB
testcase_26 AC 48 ms
12,132 KB
testcase_27 AC 30 ms
6,944 KB
testcase_28 AC 22 ms
13,056 KB
testcase_29 AC 18 ms
6,944 KB
testcase_30 AC 66 ms
9,664 KB
testcase_31 AC 41 ms
9,328 KB
testcase_32 AC 24 ms
15,292 KB
testcase_33 AC 9 ms
8,256 KB
testcase_34 AC 42 ms
21,348 KB
testcase_35 AC 11 ms
9,340 KB
testcase_36 AC 14 ms
9,952 KB
testcase_37 AC 177 ms
34,736 KB
testcase_38 AC 166 ms
34,624 KB
testcase_39 AC 173 ms
34,700 KB
testcase_40 AC 173 ms
34,632 KB
testcase_41 AC 176 ms
34,552 KB
testcase_42 AC 169 ms
34,648 KB
testcase_43 AC 172 ms
34,608 KB
testcase_44 AC 169 ms
34,660 KB
testcase_45 AC 156 ms
34,616 KB
testcase_46 AC 179 ms
34,696 KB
testcase_47 AC 57 ms
34,652 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;
  vector<ll> a(n);
  vcin(a);
  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