#abc330b. B - Minimize Abs 1

B - Minimize Abs 1

Score : 200200 points

问题描述

你给定一个整数序列 A=(A1,A2,,AN)A=(A_1,A_2,\ldots,A_N),其长度为 NN,以及满足 LRL\leq R 的整数 LLRR

对于每个 i=1,2,,Ni=1,2,\ldots,N,找出满足以下两个条件的整数 XiX_i。请注意,要找到的整数总是唯一确定的。

  • LXiRL\leq X_i \leq R
  • 对于所有满足 LYRL \leq Y \leq R 的整数 YY,都有 XiAiYAi|X_i - A_i| \leq |Y - A_i|

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

You are given an integer sequence A=(A1,A2,,AN)A=(A_1,A_2,\ldots,A_N) of length NN and integers LL and RR such that LRL\leq R.

For each i=1,2,,Ni=1,2,\ldots,N, find the integer XiX_i that satisfies both of the following conditions. Note that the integer to be found is always uniquely determined.

  • LXiRL\leq X_i \leq R.
  • For every integer YY such that LYRL \leq Y \leq R, it holds that XiAiYAi|X_i - A_i| \leq |Y - A_i|.

Constraints

  • 1N2×1051\leq N\leq 2\times 10^5
  • 1LR1091\leq L\leq R \leq 10^9
  • 1Ai1091\leq A_i\leq 10^9
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN LL RR

A1A_1 \ldots ANA_N

Output

Print XiX_i for i=1,2,,Ni=1,2,\ldots,N, separated by spaces.

Sample Input 1

5 4 7
3 1 4 9 7

Sample Output 1

4 4 4 7 7

For i=1i=1:

  • 43=1|4-3|=1
  • 53=2|5-3|=2
  • 63=3|6-3|=3
  • 73=4|7-3|=4

Thus, Xi=4X_i = 4.

Sample Input 2

3 10 10
11 10 9

Sample Output 2

10 10 10

update @ 2024/3/10 01:13:36