WA求调
查看原帖
WA求调
1243587
shiyilang0910楼主2025/1/3 16:28
#include<bits/stdc++.h>
using namespace std;
#define int long long
int t,n,a[2005];
bool check(int k){
	int c=0;
	for(int i=2;i<=n;i++){
		if (a[i]-a[i-1]<=k){
			c++;
			i++;
		}else{
			c++;
		}
	}
	if (c>=2){
		return false;
	}
	return true;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>t;
	while(t--){
		cin>>n;
		for(int i=1;i<=n;i++){
			cin>>a[i];
		}
		int l=0,r=1e18,res;
		while(l<=r){
			int mid=(l+r)/2;
			if (check(mid)){
				r=mid-1;
				res=mid;
			}else{
				l=mid+1;
			}
		}
		cout<<res<<endl;
	}
	return 0;
}
2025/1/3 16:28
加载中...