CF831C.Jury Marks
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Polycarp watched TV-show where k 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 i-th jury member gave a__i points.
Polycarp does not remember how many points the participant had before this k marks were given, but he remembers that among the scores announced after each of the k judges rated the participant there were n (n ≤ k) values _b_1, _b_2, ..., b__n (it is guaranteed that all values b__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.
Polycarp 观看了一档电视节目,其中 k 名评委依次为一名参赛者打分(所加分数可为负数,即扣分)。参赛者最初拥有某个初始分数,之后每名评委给出的分数被依次累加到该初始分数上。已知第 i 名评委给出的分数为 ai。
Polycarp 不记得参赛者在收到这 k 次评分之前的初始分数是多少,但他记得:在每位评委打分后依次公布的 k 个分数中,有 n(n≤k)个值 b1,b2,…,bn 被他记住了(保证所有 bj 互不相同)。注意,Polycarp 可能并未记住全部 k 个公布分数,即可能有 n<k。此外,初始分数本身并未被公布。
你的任务是确定参赛者在评委打分前可能拥有的初始分数的方案数。
输入格式
The first line contains two integers k and n (1 ≤ n ≤ k ≤ 2 000) — the number of jury members and the number of scores Polycarp remembers.
The second line contains k integers _a_1, _a_2, ..., a__k ( - 2 000 ≤ a__i ≤ 2 000) — jury's marks in chronological order.
The third line contains n distinct integers _b_1, _b_2, ..., b__n ( - 4 000 000 ≤ b__j ≤ 4 000 000) — the values of points Polycarp remembers. Note that these values are not necessarily given in chronological order.
第一行包含两个整数 k 和 n(1 ≤ n ≤ k ≤ 2000)—— 分别表示评委人数以及 Polycarp 记得的分数个数。
第二行包含 k 个整数 a1,a2,...,ak(−2000 ≤ ai ≤ 2000)—— 表示评委按时间顺序给出的评分。
第三行包含 n 个互不相同的整数 b1,b2,...,bn(−4000000 ≤ bj ≤ 4000000)—— 表示 Polycarp 记得的分数值。注意,这些值不一定按时间顺序给出。
输出格式
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).
输出参赛者在评委打分前可能的得分选项数量。如果Polycarp弄错了,导致不存在任何可能的得分,则输出“0”(不带引号)。
输入输出样例
输入#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 3 because initially the participant could have - 10, 10 or 15 points.
In the second example there is only one correct initial score equaling to 4 002 000.
第一个样例的答案是 3,因为初始时参与者可能有 −10、10 或 15 分。
第二个样例中仅有一个正确的初始得分,其值为 4002000。
输入解题思路,AI测评打分。不知道怎么写?