#include<iostream> #include<cstdio> #include<algorithm> #include<cmath> #include<cstring> #include<set> #define ll long long using namespace std; const int maxn = 200010; const int inf = 0x3f3f3f3f; int main() { int t; cin >> t; while (t--) { int n, q; cin >> n >> q; int a[110]; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); int contrast = a[n - 1] - a[0]; if (contrast > 2 * q) { printf("-1\n"); } else { printf("%d\n", a[0] + q); } } }
简单签到题
原文地址:https://www.cnblogs.com/csxaxx/p/11099020.html
时间: 2024-11-07 12:10:39