Codeforces Round #226 (Div. 2)A. Bear and Raspberry

时间:2021-07-26 13:47:38
 /*
    贪心的找到相邻两项差的最大值,再减去c,结果若是负数答案为0.
*/
1 #include <stdio.h>
#define maxn 105
int num[maxn];
int main()
{
int n,c;
while(~scanf("%d%d",&n,&c))
{
int ans = ;
for(int i = ;i < n;i++)
scanf("%d",num+i);
for(int i = ;i < n-;i++){
int temp = num[i] - num[i+];
if(temp > ans)
ans = temp;
}
ans -= c;
if(ans>=)
printf("%d\n",ans);
else
printf("0\n");
}
}