山东省第一届ACM省赛 D SDUT 2154 Shopping
来源:互联网 发布:用python做的网站 编辑:程序博客网 时间:2024/05/02 04:34
Shopping
Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^
题目描述
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.
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.
输入
The input consists of several test cases.
The first line of input in each test case contains one integer N (0<N<100001), represents the number of shops.
The next line contains N integers, describing the situation of the shops. You can assume that the situations of the shops are non-negative integer and smaller than 2^30.
The last case is followed by a line containing one zero.
The first line of input in each test case contains one integer N (0<N<100001), represents the number of shops.
The next line contains N integers, describing the situation of the shops. You can assume that the situations of the shops are non-negative integer and smaller than 2^30.
The last case is followed by a line containing one zero.
输出
For each test case, print the length of their shopping route.
示例输入
424 13 89 3767 30 41 14 39 420
示例输出
15270
#include <bits/stdc++.h>using namespace std;int main(){ int n,m; while(~scanf("%d",&n) && n) { int MAX = -1; int MIN = 0x3f3f3f3f; for(int i=0; i<n; i++) { scanf("%d",&m); MAX = max(MAX, m); MIN = min(MIN, m); } printf("%d\n",(MAX-MIN)*2); }}
0 0
- 山东省第一届ACM省赛 D SDUT 2154 Shopping
- Shopping(山东省第一届ACM省赛)
- 山东省第一届ACM省赛 C SDUT 2153 Clockwise
- 山东省第一届ACM省赛 F SDUT 2156 Fairy tale
- 山东省第一届ACM省赛 J SDUT 2160 Jerry Mouse
- 山东省第一届ACM大学生程序设计竞赛 Shopping 水。。。。。。。
- 2010年山东省第一届ACM大学生程序设计竞赛:shopping
- 山东省第一届ACM大学生程序设计竞赛 problemG Shopping
- 山东省第一届ACM省赛 A SDUT 2151 Phone Number(暴力)
- 山东省第一届ACM省赛 B SDUT 2152 Balloons(简单的BFS)
- 山东省第一届ACM省赛 E SDUT 2155 Emergency(最短路)
- 山东省第一届ACM省赛 G SDUT 2157 Greatest Number(暴力枚举)
- 山东省第一届ACM省赛 H SDUT 2158 Hello World!(穷举)
- 山东省第一届ACM省赛 I SDUT 2159 Ivan comes again!(STL-set)
- 山东省第一届ACM省赛 C SDUT 2153 Clockwise(dp+计算几何)
- [2010山东省第一届ACM大学生程序设计竞赛]——Shopping
- 2010年山东省第一届ACM大学生程序设计竞赛——Shopping
- 山东省第八届ACM省赛 D.HEX
- 程序员如何优雅的挣零花钱?
- WinSocket编程例子(TCP和UDP)
- 爬虫笔记
- Centos7 ssh修改默认端口号
- 多级列表的学习:ExpandableListView
- 山东省第一届ACM省赛 D SDUT 2154 Shopping
- Android ListView 几个重要属性
- 编码格式介绍
- Problem A: 判断操作是否合法(栈和队列)
- 4.传输控制协议(TCP):进程到进程的通信
- 求一段连续整数区间的和
- 前端开发学习笔记05---HTML高级教程
- iOS形变之CGAffineTransform
- Problem J: 选择法排序