CF1512F.Education

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Polycarp is wondering about buying a new computer, which costs cc tugriks. To do this, he wants to get a job as a programmer in a big company.

There are nn positions in Polycarp's company, numbered starting from one. An employee in position ii earns a[i]a[i] tugriks every day. The higher the position number, the more tugriks the employee receives. Initially, Polycarp gets a position with the number 11 and has 00 tugriks.

Each day Polycarp can do one of two things:

  • If Polycarp is in the position of xx, then he can earn a[x]a[x] tugriks.
  • If Polycarp is in the position of xx (x<nx \lt n) and has at least b[x]b[x] tugriks, then he can spend b[x]b[x] tugriks on an online course and move to the position x+1x+1.

For example, if n=4n=4, c=15c=15, a=[1,3,10,11]a=[1, 3, 10, 11], b=[1,2,7]b=[1, 2, 7], then Polycarp can act like this:

  • On the first day, Polycarp is in the 11-st position and earns 11 tugrik. Now he has 11 tugrik;
  • On the second day, Polycarp is in the 11-st position and move to the 22-nd position. Now he has 00 tugriks;
  • On the third day, Polycarp is in the 22-nd position and earns 33 tugriks. Now he has 33 tugriks;
  • On the fourth day, Polycarp is in the 22-nd position and is transferred to the 33-rd position. Now he has 11 tugriks;
  • On the fifth day, Polycarp is in the 33-rd position and earns 1010 tugriks. Now he has 1111 tugriks;
  • On the sixth day, Polycarp is in the 33-rd position and earns 1010 tugriks. Now he has 2121 tugriks;
  • Six days later, Polycarp can buy himself a new computer.

Find the minimum number of days after which Polycarp will be able to buy himself a new computer.

波利卡尔普正在考虑购买一台新电脑,价格为 cc 图格里克。为此,他想在一家大公司找一份程序员的工作。

波利卡尔普所在的公司共有 nn 个职位,编号从 11 开始。处于第 ii 个职位的员工每天可获得 a[i]a[i] 图格里克。职位编号越大,每日收入越高。初始时,波利卡尔普处于第 11 个职位,且拥有 00 图格里克。

每天,波利卡尔普可以执行以下两种操作之一:

  • 若波利卡尔普当前处于第 xx 个职位,则他可赚取 a[x]a[x] 图格里克;
  • 若波利卡尔普当前处于第 xx 个职位(其中 x<nx \lt n)且至少拥有 b[x]b[x] 图格里克,则他可花费 b[x]b[x] 图格里克报名一门在线课程,并晋升至第 x+1x+1 个职位。

例如,若 n=4n=4,c=15c=15,a=[1,3,10,11]a=[1, 3, 10, 11],b=[1,2,7]b=[1, 2, 7],则波利卡尔普可按如下方式行动:

  • 第一天:波利卡尔普处于第 11 个职位,赚取 11 图格里克,此时他拥有 11 图格里克;
  • 第二天:波利卡尔普处于第 11 个职位,花费 11 图格里克报名课程并晋升至第 22 个职位,此时他拥有 00 图格里克;
  • 第三天:波利卡尔普处于第 22 个职位,赚取 33 图格里克,此时他拥有 33 图格里克;
  • 第四天:波利卡尔普处于第 22 个职位,花费 22 图格里克报名课程并晋升至第 33 个职位,此时他拥有 11 图格里克;
  • 第五天:波利卡尔普处于第 33 个职位,赚取 1010 图格里克,此时他拥有 1111 图格里克;
  • 第六天:波利卡尔普处于第 33 个职位,赚取 1010 图格里克,此时他拥有 2121 图格里克;
  • 六天之后,波利卡尔普即可购买一台新电脑。

求波利卡尔普能够购买新电脑所需的最少天数。

输入格式

The first line contains a single integer tt (1≤t≤1041 \le t \le 10^4). Then tt test cases follow.

The first line of each test case contains two integers nn and cc (2≤n≤2⋅1052 \le n \le 2 \cdot 10^5, 1≤c≤1091 \le c \le 10^9) — the number of positions in the company and the cost of a new computer.

The second line of each test case contains nn integers a1≤a2≤…≤ana_1 \le a_2 \le \ldots \le a_n (1≤ai≤1091 \le a_i \le 10^9).

The third line of each test case contains n−1n - 1 integer b1,b2,…,bn−1b_1, b_2, \ldots, b_{n-1} (1≤bi≤1091 \le b_i \le 10^9).

It is guaranteed that the sum of nn over all test cases does not exceed 2⋅1052 \cdot 10^5.

第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4)。随后是 tt 组测试数据。

每组测试数据的第一行包含两个整数 nn 和 cc(2≤n≤2⋅1052 \le n \le 2 \cdot 10^5,1≤c≤1091 \le c \le 10^9)——分别表示公司中的岗位数量以及一台新计算机的成本。

每组测试数据的第二行包含 nn 个整数 a1≤a2≤…≤ana_1 \le a_2 \le \ldots \le a_n(1≤ai≤1091 \le a_i \le 10^9)。

每组测试数据的第三行包含 n−1n - 1 个整数 b1,b2,…,bn−1b_1, b_2, \ldots, b_{n-1}(1≤bi≤1091 \le b_i \le 10^9)。

保证所有测试数据的 nn 之和不超过 2⋅1052 \cdot 10^5。

输出格式

For each test case, output the minimum number of days after which Polycarp will be able to buy a new computer.

对于每个测试用例,输出 Polycarp 能够购买一台新电脑所需的最少天数。

输入输出样例

  • 输入#1

    3
    4 15
    1 3 10 11
    1 2 7
    4 100
    1 5 10 50
    3 14 12
    2 1000000000
    1 1
    1

    输出#1

    6
    13
    1000000000

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

首页