Accepted solution

496A - Minimum Difficulty

Open original problem
Source code

#include <iostream>

#include<vector>

#include<string>

#include<math.h>

#include<set>

#include<map>

#include<list>

#include<stack>

#include<queue>

#include <fstream>

#include<iterator>

#include<algorithm>

/* ==================================================

  |                                                  |

  |    Author: *** S. M. Sabiul Hajjaj Sabit ***     |

  |       Last Edit:  May,14,2019                    |

   ================================================== */

///***global declaration***///

#define all(arr) arr.begin(),arr.end()

#define pb push_back

#define lb lower_bound

#define up upper_bound

#define sz(x) x.size()

#define min3(a,b,c)  min(min(a,b),c)

#define max3(a,b,c)  max(max(a,b),c)

using namespace std;

int i,j,n,m,sum=0,ans=0;

template <typename T>long long int power(T a, T b)

{

    long long int pow=1;

    for(int i=0; i<b; i++)

        pow *= a;

    return pow;

}

bool doubles (double A, double ????

{

    return A <= B;

}

///*********Write Code From Here*********///

vector<int>arr;

int main()

{

    int n;

    int a,ans=999999;

    vector<int>arr,temp;

    cin>>n;

    for(int i=-0;i<n;i++)

    {

        int t;

        cin>>t;

        arr.pb(t);

    }

    for(int i=1; i<n-1;i++)

    {

        a=-1;

        temp=arr;

        temp.erase(temp.begin()+i);

        for(int j=0; j<n-1; j++)

        {

            a = max(a,(temp[j+1]-temp[j]));

        }

        ans = min(a,ans);

    }

    cout<<ans<<endl;

}
Join the discussion

Add your comment