Codeforces-SolutionsA/Codes/1853 A - Desorting/1853A.cpp

46 lines
698 B
C++
Raw Normal View History

2023-07-25 19:31:17 +08:00
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
void solve()
{
int n;
cin>>n;
vector<int>v;
for(int i=0; i<n; ++i)
{
int x;
cin>>x;
v.push_back(x);
}
2023-07-25 19:32:01 +08:00
if(!is_sorted(v.begin(),v.end()))
2023-07-25 19:31:17 +08:00
cout<<0<<endl;
else
{
int d=INT_MAX;
for(int i=1; i<n; ++i)
{
int r;
r=v[i]-v[i-1];
if(r<d)
{
d=r;
}
}
int ans=(d/2)+1;
cout<<ans<<endl;
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int TC = 1;
cin >> TC;
cin.ignore();
while (TC--) solve();
}