AtCoder Regular Contest 204 (Div. 1)
A
Use Udon Coupon
AtCoder
⌀ 1923
原题
←B →
翻译中…

Problem Statement

翻译中…

You are given positive integers $N, L, R$ and length-$N$ positive integer sequences $A = (A_{1}, A_{2}, \dots, A_{N}), B = (B_{1}, B_{2}, \dots, B_{N})$.

翻译中…

Using a sequence $Q$ initialized as empty, a variable $C$ initialized to $0$, and a variable $i$ initialized to $1$, perform the following operation $2N$ times.

翻译中…
  • Choose one of the following actions $1, 2$ and perform it.
  • Action $1$ : Insert $i$ at the end of $Q$, replace $C$ with $\max(0, C - A_{i})$. Then, increase $i$ by $1$. This action can only be performed when $i$ before the operation is at most $N$.
    • Action $2$ : Let $x$ be the first number in $Q$, and add $B_{x}$ to $C$. Then, remove the first element of $Q$. This action can only be performed when $Q$ before the operation is not empty.
翻译中…

Find the number, modulo $998244353$, of ways to perform $2N$ operations such that the final value of $C$ is between $L$ and $R$, inclusive.

翻译中…

Constraints

翻译中…
  • $1\leq N\leq 5000$
  • $1\leq L \leq R \leq \sum B$
  • $1\leq A_{i}\leq 5000$
  • $1\leq B_{i}\leq 5000$
  • All input values are integers.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N L R
A_{1} A_{2} \dots A_{N}
B_{1} B_{2} \dots B_{N}

翻译中…

Output

翻译中…

Output the answer.

翻译中…

样例

Input #1
2 100 1000
2001 167
924 178
Output #1
1
For example, you can perform four operations as follows. - Perform action $1$. Then, $Q = (1), C = 0, i = 2$. - Perform action $2$. Then, $Q = (), C = 924, i = 2$. - Perform action $1$. Then, $Q = (2), C = 757, i = 3$. - Perform action $2$. Then, $Q = (), C = 935, i = 3$. Performing operations as above makes the final value of $C$ between $100$ and $1000$ (inclusive). This is the only such way to perform operations, so output $1$.
Input #2
3 10 10
1 6 7
9 2 4
Output #2
0
Input #3
15 167 924
122 122 111 85 97 108 115 82 84 82 105 103 113 102 135
116 122 110 106 71 85 70 94 86 110 73 97 101 86 73
Output #3
9576277
题目信息
题号
arc204_a
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。