2017 ACM/ICPC 沈阳 K题 Rabbits
Help them play as long as possible
InputThe input has several test cases. The first line of input contains an integer t (1 ≤ t ≤ 500) indicating the number of test cases.
For each case the first line contains the integer N (3 ≤ N ≤ 500) described as above. The second line contains n integers a1a1 < a2a2 < a3a3 < ... < aNaN which are the initial positions of the rabbits. For each rabbit, its initial position
aiai satisfies 1 ≤ aiai ≤ 10000.
OutputFor each case, output the largest number of moves the rabbits can make.
Sample Input
5
3
3 4 6
3
2 3 5
3
3 5 9
4
1 2 3 4
4
1 2 4 5
Sample Output
1
1
3
0
1
签到题:Orz
#include<bits/stdc++.h>
using namespace std;
int T,num[],sum[];
int main()
{
scanf("%d",&T);
while(T--)
{
int n;
scanf("%d",&n);
int len=;
for(int i=;i<=n;i++) scanf("%d",&num[i]);
for(int i=;i<n;i++) sum[i]=num[i+]-num[i]-,len+=sum[i];
int ans=len-min(sum[],sum[n-]);
printf("%d\n",ans);
}
return ;
}
2017 ACM/ICPC 沈阳 K题 Rabbits的更多相关文章
- 2017 ACM/ICPC 沈阳 L题 Tree
Consider a un-rooted tree T which is not the biological significance of tree or plant, but a tree as ...
- 2017 ACM/ICPC 沈阳 I题 Little Boxes
Little boxes on the hillside. Little boxes made of ticky-tacky. Little boxes. Little boxes. Little b ...
- 2017 ACM/ICPC 沈阳 F题 Heron and his triangle
A triangle is a Heron’s triangle if it satisfies that the side lengths of it are consecutive integer ...
- 2017 ACM/ICPC 沈阳 G题 Infinite Fraction Path
The ant Welly now dedicates himself to urban infrastructure. He came to the kingdom of numbers and s ...
- 2017 ACM/ICPC Asia Regional Qingdao Online
Apple Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submi ...
- 2017 ACM/ICPC Asia Regional Shenyang Online spfa+最长路
transaction transaction transaction Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 132768/1 ...
- 2017 ACM ICPC Asia Regional - Daejeon
2017 ACM ICPC Asia Regional - Daejeon Problem A Broadcast Stations 题目描述:给出一棵树,每一个点有一个辐射距离\(p_i\)(待确定 ...
- 2017 ACM - ICPC Asia Ho Chi Minh City Regional Contest
2017 ACM - ICPC Asia Ho Chi Minh City Regional Contest A - Arranging Wine 题目描述:有\(R\)个红箱和\(W\)个白箱,将这 ...
- 2017 ACM/ICPC Shenyang Online SPFA+无向图最长路
transaction transaction transaction Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 132768/1 ...
随机推荐
- java多线程与线程并发一:线程基础回顾
本文章内容整理自:张孝祥_Java多线程与并发库高级应用视频教程 线程简单来讲就是程序正在做的事情.多线程即一个程序同时做多件事情,一个线程就是一件事情. 在java中创建线程的方法有两种. 方法一是 ...
- [Office] Resources for Office Development
Office 2013 Document (.chm) download page: http://www.microsoft.com/en-us/download/details.aspx?id=4 ...
- 前端小白在asp.net core mvc中使用ECharts
对于在浏览器中绘制图形图表,目前有较多的js类库可以使用,如:ChartJS,Flot,canvasjs等,但是今天介绍的主角为国产图表库,并在apache孵化,就是大名鼎鼎的echarts. 前方高 ...
- spring 工具类大集合
接以前的文章 apache-commons 常用工具类 和文章 apache-commons 工具类扩展 小家 Spring 对 spring 的工具类做了详细的介绍(一) 这里我抽出一些好用的类,不 ...
- (三十五)golang--面向对象之多态
多态:变量具有多种形态,可以用统一的接口来调用不同的实现. 接口体现多态特征: (1)多态参数:之前所讲的Usb接口案例,既可以接受手机变量,也可以接受相机变量,就体现了usb接口的多态: (2)多台 ...
- 理解Spark SQL(三)—— Spark SQL程序举例
上一篇说到,在Spark 2.x当中,实际上SQLContext和HiveContext是过时的,相反是采用SparkSession对象的sql函数来操作SQL语句的.使用这个函数执行SQL语句前需要 ...
- 迁移桌面程序到MS Store(12)——WPF使用UWP InkToolbar和InkCanvas
我们在<迁移桌面程序到MS Store(4)——桌面程序调用Win10 API>提到了对Win10 API的调用,但仍存在无法在WPF中使用UWP控件的问题,虽然都是XAML控件,但却是两 ...
- 五年老Android,我决定转后端开发了!
今天给大家分享一些移动端(Android)开发学习后端开发(Java Web)的一些事儿,不知道从什么时候开始身边的同事都开始陆陆续续的在朋友圈发一些后端的文章如:Nginx.Docker.k8s类的 ...
- Oracle10g安装步骤(二)
接上篇:
- 扛把子组20191114-4 Beta发布用户使用报告
此作业的要求参见:http://edu.cnblogs.com/campus/nenu/2019fall/homework/10007 小组情况: 队名:扛把子 组长:孙晓宇 组员:宋晓丽 梁梦瑶 韩 ...