Public Judge

pjudge

Time Limit: 3 s Memory Limit: 1024 MB Total points: 100 Hackable ✓
Statistics

Given an integer sequence $p_1, \dots, p_n$ of length $n$, and two non-negative integers $a$ and $b$.

For each $1 \le k \le n$, you need to choose a subsequence $q_1, \dots, q_k$ of $p$ to maximize $\sum_{i=1}^k q_i(i^2+ai+b)$.

Input

The first line contains a positive integer $T$, representing the number of test cases. The format for each test case is as follows:

  • The first line contains a positive integer $n$.
  • The second line contains $n$ integers $p_1, \dots, p_n$.
  • The third line contains two non-negative integers $a, b$.

Output

For each test case, output a single line containing $n$ integers, representing the answers for $k=1, \dots, k=n$ respectively.

Examples

Input 1

2
3
1 2 3
0 0
5
1 -1 1 -1 1
3 2

Output 1

3 14 36
6 18 38 44 26

Input 2

See provided files.

Constraints

For all test cases, it is guaranteed that $1 \le T \le 20$, $n \le 50000$, $|p_i| \le 50000$, $0 \le a, b \le 100$, and $a^2 \ge 4b$.

Subtask ID Special Constraints Score
$1$ $n \le 3000$ $20$
$2$ $p_i$ are uniformly random in $[-50000, 50000]$ $30$
$3$ $T \le 4$ $30$
$4$ $20$

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.