1046. Shortest Distance
来源:互联网 发布:淘宝摄影单反相机 编辑:程序博客网 时间:2024/06/14 11:27
Input Specification:
Each input file contains one test case. For each case, the first line contains an integer N (in [3, 105]), followed by N integer distances D1 D2 ... DN, where Di is the distance between the i-th and the (i+1)-st exits, and DN is between the N-th and the 1st exits. All the numbers in a line are separated by a space. The second line gives a positive integer M (<=104), with M lines follow, each contains a pair of exit numbers, provided that the exits are numbered from 1 to N. It is guaranteed that the total round trip distance is no more than 107.
Output Specification:
For each test case, print your results in M lines, each contains the shortest distance between the corresponding given pair of exits.
Sample Input:5 1 2 4 14 931 32 54 1Sample Output:
10
7
- 1046. Shortest Distance
- 1046. Shortest Distance (20)
- 1046. Shortest Distance
- 1046. Shortest Distance (20)
- 1046. Shortest Distance (20)
- 1046. Shortest Distance (20)
- 1046. Shortest Distance (20)
- PAT 1046. Shortest Distance
- PAT 1046. Shortest Distance
- 1046. Shortest Distance
- 1046. Shortest Distance
- 1046. Shortest Distance (20)
- 1046. Shortest Distance (20)
- PAT 1046. Shortest Distance
- 1046. Shortest Distance (20)
- 1046. Shortest Distance (20)
- 1046.Shortest Distance
- 1046. Shortest Distance (20)
- VBA:Excel使用SQL进行查询
- 别名(Alias)
- 处理机的三级调度
- hibernate自动建表到数据库及spring下自动建表到数据库
- NYOJ2 括号配对问题
- 1046. Shortest Distance
- 巧妙使用WilliamChart绘制出只有两个圆角的柱状图
- Java高并发程序设计笔记(三)之Volatile与Lock
- LeetCode 442 --- Find All Duplicates in an Array
- 1047. Student List for Course
- 知名的开源apm(Application Performance Management)工具
- LintCode之最长公共子串(Longest Common Substring)
- 组(Group)
- Android开发-自定义application对activity的管理与控制