题意可能难懂,其实就是一个人可以借一个东西,需要付出c,但是可以先欠着,然后在每一天卖出去有不同的价格,但在s天卖出必定在s+1天买进,求最大所得,可以不去借。
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
int n,c;
cin >> n >> c;
int ans = 0;
int pre,x;
scanf("%d",&pre);
for(int i = 2;i <= n;++i){
scanf("%d",&x);
ans = max(ans,pre - x - c);
pre = x;
}
cout << ans << endl;
return 0;
}