#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
#define sf scanf
#define pf printf
#define MAX 105
int a[MAX], b[MAX];
int main()
{
int n, i, j, k, max, min, sub;
sf("%d", &n);
for(i=1; i<=n; i++)
{
sf("%d", &a[i]);
}
min = 10000;
for(k=2; k<n; k++)
{
j=1;
for(i=1; i<k; i++)
{
b[j++] = a[i];
}
for(i=k+1; i<=n; i++)
{
b[j++] = a[i];
}
sub = 0;
max = 0;
for(j=1; j<n-1; j++)
{
sub = b[j+1] - b[j];
if(sub>=max)
{
max = sub;
}
}
if(max<=min)
{
min = max;
}
j=1;
for(i=1; i<=n; i++)
{
b[j++] = a[i];
}
}
pf("%d\n", min);
return 0;
}
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
#define sf scanf
#define pf printf
#define MAX 105
int a[MAX], b[MAX];
int main()
{
int n, i, j, k, max, min, sub;
sf("%d", &n);
for(i=1; i<=n; i++)
{
sf("%d", &a[i]);
}
min = 10000;
for(k=2; k<n; k++)
{
j=1;
for(i=1; i<k; i++)
{
b[j++] = a[i];
}
for(i=k+1; i<=n; i++)
{
b[j++] = a[i];
}
sub = 0;
max = 0;
for(j=1; j<n-1; j++)
{
sub = b[j+1] - b[j];
if(sub>=max)
{
max = sub;
}
}
if(max<=min)
{
min = max;
}
j=1;
for(i=1; i<=n; i++)
{
b[j++] = a[i];
}
}
pf("%d\n", min);
return 0;
}
No comments:
Post a Comment