Friday, April 4, 2014

Codeforces Round #226 (Div. 2), problem: (A) Bear and Raspberry solution

Codeforces Round #226 (Div. 2), problem: (A) Bear and Raspberry: http://codeforces.com/contest/385/problem/A

Codeforces Round #226 (Div. 2), problem: (A) Bear and Raspberry editorial: http://codeforces.com/blog/entry/10514

Codeforces Round #226 (Div. 2), problem: (A) Bear and Raspberry solution: http://ideone.com/SNDpEE


#include <iostream>
#include <cstdio>
#include <climits>
using namespace std;

int main() {
    int n, c, x[105], max, min, dif;
    max=INT_MIN;
    min=INT_MAX;
    dif=0;
    scanf("%d%d", &n, &c);
    for(int i=0; i<n; i++) scanf("%d", &x[i]);
    for(int i=0; i<n-1; i++) if(x[i]-x[i+1]>dif) max=x[i], min=x[i+1], dif=max-min;
    if(dif-c>0) printf("%d", dif-c);
    else printf("0");
    return 0;
}

No comments:

Post a Comment