CF1832D1.Red-Blue Operations (Easy Version)

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

The only difference between easy and hard versions is the maximum values of nn and qq .

You are given an array, consisting of nn integers. Initially, all elements are red.

You can apply the following operation to the array multiple times. During the ii -th operation, you select an element of the array; then:

  • if the element is red, it increases by ii and becomes blue;
  • if the element is blue, it decreases by ii and becomes red.

The operations are numbered from 11 , i. e. during the first operation some element is changed by 11 and so on.

You are asked qq queries of the following form:

  • given an integer kk , what can the largest minimum in the array be if you apply exactly kk operations to it?

Note that the operations don't affect the array between queries, all queries are asked on the initial array aa .

输入格式

The first line contains two integers nn and qq ( 1n,q10001 \le n, q \le 1000 ) — the number of elements in the array and the number of queries.

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n ( 1ai1091 \le a_i \le 10^9 ).

The third line contains qq integers k1,k2,,kqk_1, k_2, \dots, k_q ( 1kj1091 \le k_j \le 10^9 ).

输出格式

For each query, print a single integer — the largest minimum that the array can have after you apply exactly kk operations to it.

输入输出样例

  • 输入#1

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

    输出#1

    3 4 5 6 7 8 8 10 8 12
  • 输入#2

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

    输出#2

    3 4 5 6 7 8 9 8 11 8
  • 输入#3

    2 5
    2 3
    10 6 8 1 3

    输出#3

    10 7 8 3 3
首页