CF1870D.Prefix Purchase

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

You have an array aa of size nn , initially filled with zeros ( a1=a2==an=0a_1 = a_2 = \ldots = a_n = 0 ). You also have an array of integers cc of size nn .

Initially, you have kk coins. By paying cic_i coins, you can add 11 to all elements of the array aa from the first to the ii -th element ( aj+=1a_j \mathrel{+}= 1 for all 1ji1 \leq j \leq i ). You can buy any cic_i any number of times. A purchase is only possible if kcik \geq c_i , meaning that at any moment k0k \geq 0 must hold true.

Find the lexicographically largest array aa that can be obtained.

An array aa is lexicographically smaller than an array bb of the same length if and only if in the first position where aa and bb differ, the element in array aa is smaller than the corresponding element in bb .

输入格式

The first line contains a single integer tt ( 1t1041 \leq t \leq 10^4 ) — the number of test cases. This is followed by a description of the test cases.

The first line of each test case contains a single integer nn ( 1n21051 \leq n \leq 2 \cdot 10^5 ) — the size of arrays aa and cc .

The second line of each test case contains nn integers c1,c2,,cnc_1, c_2, \ldots, c_n ( 1ci1091 \leq c_i \leq 10^9 ) — the array cc .

The third line of each test case contains a single integer kk ( 1k1091 \leq k \leq 10^9 ) — the number of coins you have.

It is guaranteed that the sum of all nn values across all test cases does not exceed 21052 \cdot 10^5 .

输出格式

For each test case, output nn integers a1,a2,,ana_1, a_2, \ldots, a_n — the lexicographically largest array aa that can be obtained.

输入输出样例

  • 输入#1

    4
    3
    1 2 3
    5
    2
    3 4
    7
    3
    3 2 1
    2
    6
    10 6 4 6 3 4
    7

    输出#1

    5 0 0 
    2 1 
    2 2 2 
    2 2 2 2 2 1

说明/提示

In the first test case, a1a_1 cannot be greater than 55 , and if we buy c1c_1 five times, we will run out of money, so a=[5,0,0]a = [5, 0, 0] .

In the second test case, a1a_1 cannot be greater than 22 , but we can buy c1c_1 and c2c_2 once each (buying c2c_2 twice is not possible), so a=[2,1]a = [2, 1] .

首页