CF1742E.Scuza

普及-

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Timur has a stairway with nn steps. The ii-th step is aia_i meters higher than its predecessor. The first step is a1a_1 meters higher than the ground, and the ground starts at 00 meters.

The stairs for the first test case.

Timur has qq questions, each denoted by an integer k1,…,kqk_1, \dots, k_q. For each question kik_i, you have to print the maximum possible height Timur can achieve by climbing the steps if his legs are of length kik_i. Timur can only climb the jj-th step if his legs are of length at least aja_j. In other words, ki≥ajk_i \geq a_j for each step jj climbed.

Note that you should answer each question independently.

蒂穆尔有一段有 nn 级的楼梯。第 ii 级台阶比其前一级高 aia_i 米。第一级台阶比地面高 a1a_1 米,而地面高度为 00 米。

第一个测试用例对应的楼梯示意图。

蒂穆尔有 qq 个问题,分别用整数 k1,…,kqk_1, \dots, k_q 表示。对每个问题 kik_i,你需要输出:当蒂穆尔的腿长为 kik_i 时,他通过攀爬台阶所能达到的最大高度。蒂穆尔仅当腿长至少为 aja_j 时,才能攀爬第 jj 级台阶。换言之,对于他所攀爬的每一级台阶 jj,都必须满足 ki≥ajk_i \geq a_j。

注意:每个问题需独立作答。

输入格式

The first line contains a single integer tt (1≤t≤1001 \leq t \leq 100) — the number of test cases.

The first line of each test case contains two integers n,qn, q (1≤n,q≤2⋅1051 \leq n, q \leq 2\cdot10^5) — the number of steps and the number of questions, respectively.

The second line of each test case contains nn integers (1≤ai≤1091 \leq a_i \leq 10^9) — the height of the steps.

The third line of each test case contains qq integers (0≤ki≤1090 \leq k_i \leq 10^9) — the numbers for each question.

It is guaranteed that the sum of nn does not exceed 2⋅1052\cdot10^5, and the sum of qq does not exceed 2⋅1052\cdot10^5.

第一行包含一个整数 tt(1≤t≤1001 \leq t \leq 100)—— 表示测试用例的数量。

每个测试用例的第一行包含两个整数 n,qn, q(1≤n,q≤2⋅1051 \leq n, q \leq 2\cdot10^5)—— 分别表示台阶的阶数和问题的数量。

每个测试用例的第二行包含 nn 个整数(1≤ai≤1091 \leq a_i \leq 10^9)—— 表示各阶台阶的高度。

每个测试用例的第三行包含 qq 个整数(0≤ki≤1090 \leq k_i \leq 10^9)—— 表示每个问题中的数值。

保证所有测试用例中 nn 的总和不超过 2⋅1052\cdot10^5,且所有测试用例中 qq 的总和不超过 2⋅1052\cdot10^5。

输出格式

For each test case, output a single line containing qq integers, the answer for each question.

Please note, that the answer for some questions won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).

对于每个测试用例,输出一行,包含 qq 个整数,分别对应每个问题的答案。

请注意,某些问题的答案无法用 32 位整数类型表示,因此在编程语言中应至少使用 64 位整数类型(例如 C++ 中的 long long)。

输入输出样例

  • 输入#1

    3
    4 5
    1 2 1 5
    1 2 4 9 10
    2 2
    1 1
    0 1
    3 1
    1000000000 1000000000 1000000000
    1000000000

    输出#1

    1 4 4 9 9 
    0 2 
    3000000000

说明/提示

Consider the first test case, pictured in the statement.

  • If Timur's legs have length 11, then he can only climb stair 11, so the highest he can reach is 11 meter.
  • If Timur's legs have length 22 or 44, then he can only climb stairs 11, 22, and 33, so the highest he can reach is 1+2+1=41+2+1=4 meters.
  • If Timur's legs have length 99 or 1010, then he can climb the whole staircase, so the highest he can reach is 1+2+1+5=91+2+1+5=9 meters.

In the first question of the second test case, Timur has no legs, so he cannot go up even a single step. :(

考虑题目描述中给出的第一个测试用例。

  • 若 Timur 的腿长为 11,则他只能登上第 11 级台阶,因此他能达到的最高高度为 11 米。
  • 若 Timur 的腿长为 22 或 44,则他只能登上第 11、22 和 33 级台阶,因此他能达到的最高高度为 1+2+1=41+2+1=4 米。
  • 若 Timur 的腿长为 99 或 1010,则他可以登上整段楼梯,因此他能达到的最高高度为 1+2+1+5=91+2+1+5=9 米。

在第二个测试用例的第一个问题中,Timur 没有腿,因此他甚至无法登上一级台阶。:(

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

首页