当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3427:Ecology tax

题目描述

In a big and rich on natural resources country, the government started a campaign to control deforestation. In fact the government is not too interested in how many trees get fallen, but rather how effectively the wood is utilized. So a law was passed which requires every logging company to pay amount of money in proportion to amount of wood that it wastes during operation.

A felling quota on some territory was allotted to a company in this country. Company lorries may only transport logs of exactly L meters long. So when a tree gets sawed into logs, the remainder is wasted.

Trees in this country grow exactly 1 meter per year, so the company may decrease the amount of tax to be paid by simply waiting for some years. Your task is to determine the number of years needed to achieve smallest possible tax. If there is more than one answer, find minimal (earliest) one.

输入解释

Input file contains number of trees N, length of log L, followed by integers i1 i2 ... iN — heights of each tree.

Constraints

1 ≤ N ≤ 30000, 1 ≤ L, ik ≤ 30000

输出解释

Output file must contain single integer — number of years to wait.

输入样例
Sample Input 1
3 1 
10 15 11
Sample Input 2
3 2
5 3 6
输出样例
Sample Output 1
0
Sample Output 2
1
提示

Bold texts appearing in the sample sections are informative and do not form part of the actual data.


该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3427

最后修改于 2020-10-29T07:01:22+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536