A11144 | Prefix Sums
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Consider the function $p(x)$ , where $x$ is an array of $m$ integers, which returns an array $y$ consisting of $m+1$ integers such that $y_{i}$ is equal to the sum of first $i$ elements of array $x$ ( $0<=i<=m$ ).
You have an infinite sequence of arrays $A^{0},A^{1},A^{2}...$ , where $A^{0}$ is given in the input, and for each $i>=1$ $A^{i}=p(A^{i-1})$ . Also you have a positive integer $k$ . You have to find minimum possible $i$ such that $A^{i}$ contains a number which is larger or equal than $k$ .
You have an infinite sequence of arrays $A^{0},A^{1},A^{2}...$ , where $A^{0}$ is given in the input, and for each $i>=1$ $A^{i}=p(A^{i-1})$ . Also you have a positive integer $k$ . You have to find minimum possible $i$ such that $A^{i}$ contains a number which is larger or equal than $k$ .
输入格式
The first line contains two integers $n$ and $k$ ( $2<=n<=200000$ , $1<=k<=10^{18}$ ). $n$ is the size of array $A^{0}$ .
The second line contains $n$ integers $A^{0}_{0},A^{0}_{1}...\ A^{0}_{n-1}$ — the elements of $A^{0}$ ( $0<=A^{0}_{i}<=10^{9}$ ). At least two elements of $A^{0}$ are positive.
The second line contains $n$ integers $A^{0}_{0},A^{0}_{1}...\ A^{0}_{n-1}$ — the elements of $A^{0}$ ( $0<=A^{0}_{i}<=10^{9}$ ). At least two elements of $A^{0}$ are positive.
输出格式
Print the minimum $i$ such that $A^{i}$ contains a number which is larger or equal than $k$ .
输入输出样例
输入 #1
2 2 1 1
输出 #1
1
输入 #2
3 6 1 1 1
输出 #2
2
输入 #3
3 1 1 0 1
输出 #3
0
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted