Codeforces Round #570 (Div. 3) B. Equalize Prices
作者:互联网
#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); } } }
简单签到题
标签:const,int,570,Codeforces,long,cin,Equalize,printf,include 来源: https://www.cnblogs.com/csxaxx/p/11099020.html