CF2209B.Array

入门

通过率:0%

时间限制:1.50s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given an integer array aa of length nn.

For each index ii, find the maximum number of indices jj such that j>ij \gt i and ∣ai−k∣>∣aj−k∣|a_i - k| \gt |a_j - k|, over all possible integer values of kk.

给你一个长度为 nn 的整数数组 aa。

对于每个下标 ii,求在所有可能的整数 kk 取值中,满足 j>ij \gt i 且 ∣ai−k∣>∣aj−k∣|a_i - k| \gt |a_j - k| 的下标 jj 的最大个数。

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤1001 \le t \le 100). The description of the test cases follows.

The first line of each test case contains an integer nn (1≤n≤50001 \le n \le 5000).

The second line contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (−109≤ai≤109-10^9 \le a_i \le 10^9).

It is guaranteed that the sum of nn over all test cases does not exceed 50005000.

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤1001 \le t \le 100)。随后是各测试用例的描述。

每个测试用例的第一行包含一个整数 nn(1≤n≤50001 \le n \le 5000)。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(−109≤ai≤109-10^9 \le a_i \le 10^9)。

保证所有测试用例的 nn 值之和不超过 50005000。

输出格式

For each test case, output nn integers denoting the answer.

对于每个测试用例,输出 nn 个整数表示答案。

输入输出样例

  • 输入#1

    6
    1
    1092
    2
    105 -105
    5
    1 2 93 84 2
    7
    2 9 38 4 7 1 6
    10
    1 9 20 9 829 3 87 1 283 7
    11
    9 18 29817 283 3 3928 5726 1942 1000000000 -1000000000 19

    输出#1

    0
    1 0
    4 2 2 1 0
    5 4 4 2 2 1 0
    8 4 4 3 5 3 2 2 1 0
    8 7 7 4 5 3 3 2 2 1 0

说明/提示

In the second test, the answers are:

  • For i=1i=1, you can choose k=−195k=-195, then j=2j=2.
  • For i=2i=2, you can choose k=5k=5, there exists no index j>ij \gt i.

In the third test, the answers are:

  • For i=1i=1, you can choose k=195k=195, then j=2,3,4,5j=2,3,4,5.
  • For i=2i=2, you can choose k=78k=78, then j=3,4j=3,4.
  • For i=3i=3, you can choose k=15k=15, then j=4,5j=4,5.
  • For i=4i=4, you can choose k=15k=15, then j=5j=5.
  • For i=5i=5, you can choose k=998 244 353k=998\,244\,353, there exists no index j>ij \gt i.

在第二个测试中,答案为:

  • 对于 i=1i=1,可选择 k=−195k=-195,此时 j=2j=2。
  • 对于 i=2i=2,可选择 k=5k=5,不存在满足 j>ij \gt i 的下标 jj。

在第三个测试中,答案为:

  • 对于 i=1i=1,可选择 k=195k=195,此时 j=2,3,4,5j=2,3,4,5。
  • 对于 i=2i=2,可选择 k=78k=78,此时 j=3,4j=3,4。
  • 对于 i=3i=3,可选择 k=15k=15,此时 j=4,5j=4,5。
  • 对于 i=4i=4,可选择 k=15k=15,此时 j=5j=5。
  • 对于 i=5i=5,可选择 k=998 244 353k=998\,244\,353,不存在满足 j>ij \gt i 的下标 jj。

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

首页