CF837F.Prefix Sums

提高+/省选-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

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.

考虑函数 p(x)p(x),其中 xx 是一个包含 mm 个整数的数组,该函数返回一个包含 m+1m+1 个整数的数组 yy,使得对每个 0≤i≤m0 \le i \le m,yiy_i 等于数组 xx 的前 ii 个元素之和。

你有一个无限数组序列 A0, A1, A2, …A_0,\ A_1,\ A_2,\ \dots,其中 A0A_0 由输入给出,且对每个 i≥1i \ge 1,有 Ai=p(Ai−1)A_i = p(A_{i-1})。此外,你还有一个正整数 kk。你需要找出最小的可能的 ii,使得 AiA_i 中包含一个大于或等于 kk 的数。

输入格式

The first line contains two integers n and k (2 ≤ n ≤ 200000, 1 ≤ k ≤ 1018). n is the size of array _A_0.

The second line contains n integers _A_00, _A_01... A_0_n - 1 — the elements of _A_0 (0 ≤ A_0_i ≤ 109). At least two elements of _A_0 are positive.

第一行包含两个整数 nn 和 kk(2≤n≤2000002 \leq n \leq 200000,1≤k≤10181 \leq k \leq 10^{18})。nn 是数组 A0A_0 的大小。

第二行包含 nn 个整数 A0,0, A0,1, …, A0,n−1A_{0,0},\ A_{0,1},\ \dots,\ A_{0,n-1} —— 即 A0A_0 的元素(0≤A0,i≤1090 \leq A_{0,i} \leq 10^9)。A0A_0 中至少有两个元素为正数。

输出格式

Print the minimum i such that A__i contains a number which is larger or equal than k.

输出满足条件的最小下标 ii,使得集合 AiA_i 中包含一个大于或等于 kk 的数。

输入输出样例

  • 输入#1

    2 2
    1 1

    输出#1

    1
  • 输入#2

    3 6
    1 1 1

    输出#2

    2
  • 输入#3

    3 1
    1 0 1

    输出#3

    0

输入解题思路,AI测评打分。不知道怎么写?

首页