sdnu1138shopping
来源:互联网 发布:无锡移动网络办理 编辑:程序博客网 时间:2024/06/05 05:36
1138.Shopping
Time Limit: 1000 MS Memory Limit: 32768 KB
Total Submission(s): 91 Accepted Submission(s): 57
Description
Saya and Kudo go shopping together.
You can assume the street as a straight line, while the shops are some points on the line.
They park their car at the leftmost shop, visit all the shops from left to right, and go back to their car.
Your task is to calculate the length of their route.
Input
The input consists of several test cases.
The first line of input in each test case contains one integer N (0
#include<cstdio>#include<algorithm>using namespace std;#define r 100001int main(){ int j[r],a,b,i; while(scanf("%d",&a)!=EOF&&a!=0) { b=0; for(i=0;i<a;i++) { scanf("%d",&j[i]); } sort(j,j+a); for(i=0;i<a-1;i++) { b+=j[i+1]-j[i]; } b=b+j[i]-j[0]; printf("%d\n",b); } return 0;}
阅读全文
0 0
- sdnu1138shopping
- 数据结构——数组-有序矩阵查找算法
- 国家省市区四级联动
- luogu P1948 [USACO08JAN]电话线Telephone Lines
- c++基础之define宏定义
- LeanCloud save object fail
- sdnu1138shopping
- sRGB色域与NTSC色域
- ESP32-使用eFuse 固化VDD_SDIO支持电压,释放GPIO12
- 47. Permutations II
- 通过序列和触发器实现Oracle主键自增长
- Java的方法重载规则
- 关于两个常用网络命令原理和一点说明
- Hibernate 注解映射使用方式案例
- Nginx主配置参数详解,Nginx配置网站