Codeforces 385A Bear and Raspberry(水题)

题目链接:Codeforces 385A Bear and Raspberry


题目大意:就是给出一个序列,然后相邻两个数之间差的最大值于C的差,小于0的话要输出0.


解题思路:水题。


#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

const int N = 105;

int n, c, a[N];

int main () {
	int ans = 0;
	scanf("%d%d", &n, &c);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	for (int i = 1; i < n; i++) ans = max(ans, a[i-1] - a[i]);
	printf("%d\n", max(ans - c, 0));
	return 0;
}


你可能感兴趣的:(Codeforces 385A Bear and Raspberry(水题))