CF1540C1.Converging Array (Easy Version)

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

This is the easy version of the problem. The only difference is that in this version q=1q = 1 . You can make hacks only if both versions of the problem are solved.

There is a process that takes place on arrays aa and bb of length nn and length n1n-1 respectively.

The process is an infinite sequence of operations. Each operation is as follows:

  • First, choose a random integer ii ( 1in11 \le i \le n-1 ).
  • Then, simultaneously set ai=min(ai,ai+ai+1bi2)a_i = \min\left(a_i, \frac{a_i+a_{i+1}-b_i}{2}\right) and ai+1=max(ai+1,ai+ai+1+bi2)a_{i+1} = \max\left(a_{i+1}, \frac{a_i+a_{i+1}+b_i}{2}\right) without any rounding (so values may become non-integer).

See notes for an example of an operation.It can be proven that array aa converges, i. e. for each ii there exists a limit aia_i converges to. Let function F(a,b)F(a, b) return the value a1a_1 converges to after a process on aa and bb .

You are given array bb , but not array aa . However, you are given a third array cc . Array aa is good if it contains only integers and satisfies 0aici0 \leq a_i \leq c_i for 1in1 \leq i \leq n .

Your task is to count the number of good arrays aa where F(a,b)xF(a, b) \geq x for qq values of xx . Since the number of arrays can be very large, print it modulo 109+710^9+7 .

输入格式

The first line contains a single integer nn ( 2n1002 \le n \le 100 ).

The second line contains nn integers c1,c2,cnc_1, c_2 \ldots, c_n ( 0ci1000 \le c_i \le 100 ).

The third line contains n1n-1 integers b1,b2,,bn1b_1, b_2, \ldots, b_{n-1} ( 0bi1000 \le b_i \le 100 ).

The fourth line contains a single integer qq ( q=1q=1 ).

The fifth line contains qq space separated integers x1,x2,,xqx_1, x_2, \ldots, x_q ( 105xi105-10^5 \le x_i \le 10^5 ).

输出格式

Output qq integers, where the ii -th integer is the answer to the ii -th query, i. e. the number of good arrays aa where F(a,b)xiF(a, b) \geq x_i modulo 109+710^9+7 .

输入输出样例

  • 输入#1

    3
    2 3 4
    2 1
    1
    -1

    输出#1

    56

说明/提示

The following explanation assumes b=[2,1]b = [2, 1] and c=[2,3,4]c=[2, 3, 4] (as in the sample).

Examples of arrays aa that are not good:

  • a=[3,2,3]a = [3, 2, 3] is not good because a1>c1a_1 > c_1 ;
  • a=[0,1,3]a = [0, -1, 3] is not good because a2<0a_2 < 0 .

One possible good array aa is [0,2,4][0, 2, 4] . We can show that no operation has any effect on this array, so F(a,b)=a1=0F(a, b) = a_1 = 0 .

Another possible good array aa is [0,1,4][0, 1, 4] . In a single operation with i=1i = 1 , we set a1=min(0+122,0)a_1 = \min(\frac{0+1-2}{2}, 0) and a2=max(0+1+22,1)a_2 = \max(\frac{0+1+2}{2}, 1) . So, after a single operation with i=1i = 1 , aa becomes equal to [12,32,4][-\frac{1}{2}, \frac{3}{2}, 4] . We can show that no operation has any effect on this array, so F(a,b)=12F(a, b) = -\frac{1}{2} .

首页