CF831C.Jury Marks

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Polycarp watched TV-show where kk jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the ii -th jury member gave aia_{i} points.

Polycarp does not remember how many points the participant had before this kk marks were given, but he remembers that among the scores announced after each of the kk judges rated the participant there were nn ( n<=kn<=k ) values b1,b2,...,bnb_{1},b_{2},...,b_{n} (it is guaranteed that all values bjb_{j} are distinct). It is possible that Polycarp remembers not all of the scores announced, i. e. n<k . Note that the initial score wasn't announced.

Your task is to determine the number of options for the score the participant could have before the judges rated the participant.

输入格式

The first line contains two integers kk and nn ( 1<=n<=k<=20001<=n<=k<=2000 ) — the number of jury members and the number of scores Polycarp remembers.

The second line contains kk integers a1,a2,...,aka_{1},a_{2},...,a_{k} ( 2000<=ai<=2000-2000<=a_{i}<=2000 ) — jury's marks in chronological order.

The third line contains nn distinct integers b1,b2,...,bnb_{1},b_{2},...,b_{n} ( 4000000<=bj<=4000000-4000000<=b_{j}<=4000000 ) — the values of points Polycarp remembers. Note that these values are not necessarily given in chronological order.

输出格式

Print the number of options for the score the participant could have before the judges rated the participant. If Polycarp messes something up and there is no options, print "0" (without quotes).

输入输出样例

  • 输入#1

    4 1
    -5 5 0 20
    10
    

    输出#1

    3
    
  • 输入#2

    2 2
    -2000 -2000
    3998000 4000000
    

    输出#2

    1
    

说明/提示

The answer for the first example is 33 because initially the participant could have 10-10 , 1010 or 1515 points.

In the second example there is only one correct initial score equaling to 40020004002000 .

首页