B. Messages

output
standard output

There are n incoming messages for Vasya. The i-th message is going to be received after ti minutes. Each message has a cost, which equals to A initially. After being received, the cost of a message decreases by B each minute (it can become negative). Vasya can read any message after receiving it at any moment of time. After reading the message, Vasya's bank account receives the current cost of this message. Initially, Vasya's bank account is at 0.

Also, each minute Vasya's bank account receives C·k, where k is the amount of received but unread messages.

Vasya's messages are very important to him, and because of that he wants to have all messages read after T minutes.

Determine the maximum amount of money Vasya's bank account can hold after T minutes.

Input

The first line contains five integers nABC and T (1 ≤ n, A, B, C, T ≤ 1000).

The second string contains n integers ti (1 ≤ ti ≤ T).

Output

Output one integer  — the answer to the problem.

Examples
input
Copy
4 5 5 3 5
1 5 5 4
output
Copy
20
input
Copy
5 3 1 1 3
2 2 2 1 1
output
Copy
15
input
Copy
5 5 3 4 5
1 2 3 4 5
output
Copy
35
Note

In the first sample the messages must be read immediately after receiving, Vasya receives A points for each message, n·A = 20 in total.

In the second sample the messages can be read at any integer moment.

In the third sample messages must be read at the moment T. This way Vasya has 1234 and 0 unread messages at the corresponding minutes, he gets 40 points for them. When reading messages, he receives (5 - 4·3) + (5 - 3·3) + (5 - 2·3) + (5 - 1·3) + 5 =  - 5 points. This is 35 in total.

翻译肯定不太靠不,还是要看自己。

有关Vasya的n个传入消息。第i条消息将在ti分钟后被接收。每条消息都有一个成本,最初等于A.收到消息后,消息成本每分钟减少B(可能变为负值)。 Vasya可以在任何时候收到任何消息。在阅读邮件后,Vasya的银行账户将收到此邮件的当前费用。最初,Vasya的银行账户为0。
此外,Vasya的每一分钟的银行账户都会收到C·k,其中k是收到但未读消息的数量。
瓦西亚的信息对他来说非常重要,因为他希望在T分钟后阅读所有信息。
确定Vasya银行账户在T分钟后可以持有的最大金额。
输入
第一行包含五个整数n,A,B,C和T(1≤n,A,B,C,T≤1000)。
第二个字符串包含n个整数ti(1≤ti≤T)。
产量
输出一个整数 - 问题的答案。
在第一个样本中,消息必须在收到后立即被读取,Vasya为每条消息收到A分,n·A = 20。
在第二个示例中,可以在任何整数时刻读取消息。
在第三个示例中,必须在T时刻读取消息。这样,Vasya在相应的分钟处有1,2,3,4和0条未读消息,他们得到40分。阅读信息时,他会收到(5 - 4 3)+(5 - 3 3)+(5 - 2 3)+(5 - 1 3)+ 5 = - 5分。总共有35个。

附上一个短小精悍的代码,希望你们能懂(其实就是比较大小)

#include<iostream>
using namespace std;
int main()
{
    int n,a,b,c,t,sum=0,s;
    cin>>n>>a>>b>>c>>t;
    for(int i=0; i<n; i++)
        cin>>s,sum+=t-s;
    cout<<max((n*a),(n*a)+sum*(c-b))<<endl;
    return 0;
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值