Rabbits UVALive - 8211
题意:
n个兔子的位置,兔子每次可以跳到两个兔子之间,问最多可以跳多少下?
题解:
求出所有相邻两数的间隔,然后减去最小间隔就是答案
代码:
#include <bits/stdc++.h>
using namespace std;
#define asd cout<<" SB "<<endl;
#define ll long long
#define INF 0x3f3f3f3f
const int maxn=600;
int a[maxn];
int main(){int t;scanf("%d",&t);while(t--){int n;scanf("%d",&n);int minn=1e9;ll sum=0;for(int i=1;i<=n;i++){scanf("%d",&a[i]);if(i>1){minn=min(a[i]-a[i-1]-1,minn);sum+=a[i]-a[i-1]-1;}}sum-=minn;printf("%lld\n",sum);}return 0;
}