A10968 | Jury Marks
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 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.
输入格式
The first line contains two integers $k$ and $n$ ( $1<=n<=k<=2000$ ) — the number of jury members and the number of scores Polycarp remembers.
The second line contains $k$ integers $a_{1},a_{2},...,a_{k}$ ( $-2000<=a_{i}<=2000$ ) — jury's marks in chronological order.
The third line contains $n$ distinct integers $b_{1},b_{2},...,b_{n}$ ( $-4000000<=b_{j}<=4000000$ ) — the values of points Polycarp remembers. Note that these values are not necessarily given in chronological order.
The second line contains $k$ integers $a_{1},a_{2},...,a_{k}$ ( $-2000<=a_{i}<=2000$ ) — jury's marks in chronological order.
The third line contains $n$ distinct integers $b_{1},b_{2},...,b_{n}$ ( $-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 $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 $4002000$ .
In the second example there is only one correct initial score equaling to $4002000$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted