#include<stdio.h>
int main()
{
int n,m,a,b,tem,pre,p;
int i,j;
int ans[];
while(scanf("%d",&n)!=EOF)
{
ans[]=;
for(i=;i<=n;i++)
{
scanf("%d",&tem);
ans[i]=ans[i-]+tem;
}
getchar();
scanf("%d",&m);
for(i=;i<m;i++)
{
getchar();
scanf("%d %d",&a,&b);
if(a<b)
{
pre=a;
p=b;
}
else
{
p=a;
pre=b;
} int sum1=ans[p-]-ans[pre-];
int sum2=ans[pre-]+ans[n]-ans[p-]; printf("%d\n",sum1<sum2?sum1:sum2);
}
} return ;
}

1046 Shortest Distance (20)的更多相关文章

  1. PAT甲 1046. Shortest Distance (20) 2016-09-09 23:17 22人阅读 评论(0) 收藏

    1046. Shortest Distance (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The ...

  2. 1046 Shortest Distance (20 分)

    1046 Shortest Distance (20 分) The task is really simple: given N exits on a highway which forms a si ...

  3. PAT 甲级 1046 Shortest Distance (20 分)(前缀和,想了一会儿)

    1046 Shortest Distance (20 分)   The task is really simple: given N exits on a highway which forms a ...

  4. PAT (Advanced Level) Practice 1046 Shortest Distance (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1046 Shortest Distance (20 分) 凌宸1642 题目描述: The task is really simple: ...

  5. PAT Advanced 1046 Shortest Distance (20 分) (知识点:贪心算法)

    The task is really simple: given N exits on a highway which forms a simple cycle, you are supposed t ...

  6. 1046 Shortest Distance (20分)

    The task is really simple: given N exits on a highway which forms a simple cycle, you are supposed t ...

  7. PAT (Advanced Level) 1046. Shortest Distance (20)

    处理一下前缀和. #include<iostream> #include<cstring> #include<cmath> #include<algorith ...

  8. PAT甲题题解-1046. Shortest Distance (20)-做了一个假的最短路,水

    一开始以为是最短路,结果是给你一个环,让你求环上两点之间的距离...那还做毛线 然而还是得做毛线 #include <iostream> #include <cstdio> # ...

  9. 【PAT甲级】1046 Shortest Distance (20 分)

    题意: 输入一个正整数N(<=1e5),代表出口的数量,接下来输入N个正整数表示当前出口到下一个出口的距离.接着输入一个正整数M(<=10000),代表询问的次数,每次询问输入两个出口的序 ...

随机推荐

  1. python(5) - 冒泡排序

    data = [10, 4, 33, 21, 54, 3, 8, 11, 5, 22, 2, 1, 17, 13] ''' 思路:有多少个元素就循环多少次,每次循环从第一个元素开始与它后面的元素比较, ...

  2. XML&nbsp; XmlDocument

    1.SelectSingleNode(xPath)  xPxth:xml/cam/type  一层一层递进

  3. 如何添加PPA

    什么是PPA? PPA(Personal Package Archive)相当于一个软件仓库,与Windows在网上随意抓取EXE安装包不同,PPA里面的软件都是经过审核的. 如何添加PPA? sud ...

  4. AutoCAD 2014 win 32bit破解版

    AutoCAD 2014 win 32bit破解版 百度云盘:http://pan.baidu.com/s/1nu2u6Hr

  5. 转:传入的表格格式数据流(TDS)远程过程调用(RPC)协议流不正确 .

    近期在做淘宝客的项目,大家都知道,淘宝的商品详细描述字符长度很大,所以就导致了今天出现了一个问题 VS的报错是这样子的  ” 传入的表格格式数据流(TDS)远程过程调用(RPC)协议流不正确“ 还说某 ...

  6. Https要点

    http和https的区别 1.https协议需要到ca申请证书 2.http是超文本传输协议,信息是明文传输,https 则是具有安全性的ssl加密传输协议 3.http和https使用的是完全不同 ...

  7. Font Awesome图标字体库(2015年05月25日)

    Font Awesome是一款非常棒的字体图标工具,给个地址,具体的自已慢慢去体会,只能帮你到这儿了...... http://fortawesome.github.io/Font-Awesome/ ...

  8. JS轮播图

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  9. Git CMD - reset: Reset current HEAD to the specified state

    命令格式 git reset [-q] [<tree-ish>] [--] <paths>…​ git reset (--patch | -p) [<tree-ish&g ...

  10. SVN对unity3d项目版本进行管理的不方便问题,研究ing

    unity3d项目版本控制遇到些问题,找了以下资料做参考,现在mark一下,以后慢慢解决,之后总结. Unity开启meta. meta:版本控制文件,在新加入项时,Unity3D会产生一个同名的.m ...