#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 503
int a[N];
int main() {
int T, i, j, n;
scanf("%d", &T);
while (T--) {
scanf("%d", &n);
int ans = 0;
for (i = 1;i <= n;i++) {
scanf("%d", a+i);
}
for (i = 2;i < n;i++) {
ans += a[i+1]-a[i]-1;
}
int ans1 = 0;
for (i = n-1;i > 1;i--) {
ans1 += a[i]-a[i-1]-1;
}
printf("%d\n", max(ans1, ans));
}
}
【HDU 6227 2017ACM/ICPC亚洲区沈阳站】Rabbits
最新推荐文章于 2020-02-16 16:55:54 发布