2000Robbers

2000   Robbers

题目描述

N robbers have robbed the bank. As the result of their crime they chanced to get M golden coins. Before the robbery the band has made an agreement that after the robbery i-th gangster would get Xi=Y of all money gained. However, it turned out that M may be not divisible by Y.

The problem which now should be solved by robbers is what to do with the coins. They would like to share them fairly. Let us suppose that i-th robber would get Ki coins. In this case unfairness of this fact is |Xi/Y - Ki/M|. The total unfairness is the sum of all particular unfairnesses. Your task as the leader of the gang is to spread money among robbers in such a way that the total unfairness is minimized.


This problem contains multiple test cases!

The first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.

The output format consists of N output blocks. There is a blank line between output blocks.


输入格式:

The first line of the input file contains numbers N, M and Y (1 <= N <= 1000, 1 <= M, Y <= 10000). N integer numbers follow - Xi (1 <= Xi <= 10000, sum of all Xi is Y).


输出格式:

Output N integer numbers - Ki (sum of all Ki must be M), so that the total unfairness is minimal.


输入样例 复制
1

3 10 4
1 1 2
输出样例 复制
2 3 5

说明

1
4
通过提交
时空限制5000ms/32mb
题目来源Andrew Stankevich's Contest #2
评测方式在线评测
题目类型
难        度