/*
贪心的找到相邻两项差的最大值,再减去c,结果若是负数答案为0.
*/
1 #include <stdio.h> 2 #define maxn 105 3 int num[maxn]; 4 int main() 5 { 6 int n,c; 7 while(~scanf("%d%d",&n,&c)) 8 { 9 int ans = 0; 10 for(int i = 0;i < n;i++) 11 scanf("%d",num+i); 12 for(int i = 0;i < n-1;i++){ 13 int temp = num[i] - num[i+1]; 14 if(temp > ans) 15 ans = temp; 16 } 17 ans -= c; 18 if(ans>=0) 19 printf("%d ",ans); 20 else 21 printf("0 "); 22 } 23 }