1046. Shortest Distance (20)
来源:互联网 发布:郑州八度网络怎么样 编辑:程序博客网 时间:2024/06/05 00:20
题目:https://www.patest.cn/contests/pat-a-practise/1046
#include<cstdio>#include<algorithm>using namespace std;#define MAXN 100010int dis[MAXN]={0},W[MAXN],sum=0,n=0,m=0;int main(){ scanf("%d",&n); for(int i=1; i<=n; i++) { scanf("%d",&W[i]); dis[i] = dis[i-1] + W[i]; sum = sum + W[i]; } scanf("%d",&m); for(int i=0; i<m; i++) { int x,y; scanf("%d%d",&x,&y); if(x>y) swap(x,y); int a = dis[y-1] - dis[x-1]; int b = sum - a; printf("%d\n",min(a,b)); } return 0;}
0 0
- 1046. Shortest Distance (20)
- 1046. Shortest Distance (20)
- 1046. Shortest Distance (20)
- 1046. Shortest Distance (20)
- 1046. Shortest Distance (20)
- 1046. Shortest Distance (20)
- 1046. Shortest Distance (20)
- 1046. Shortest Distance (20)
- 1046. Shortest Distance (20)
- 1046. Shortest Distance (20)
- 1046. Shortest Distance (20)
- 1046. Shortest Distance (20)
- 1046. Shortest Distance (20)
- 1046. Shortest Distance (20)
- 1046. Shortest Distance (20)
- 1046. Shortest Distance (20)
- 1046. Shortest Distance (20)
- 1046. Shortest Distance (20)
- 1044. Shopping in Mars (25)
- tensorflow代码全解析 -2- 深度强化网络 Flappy Bird with DQ
- hadoop集群运行运行wordcount
- windows下跨平台开发环境搭建(vagrant + vbox)
- 初学Singleton单例模式
- 1046. Shortest Distance (20)
- 【HTML】学校宣传单
- 输出日期
- 打电话的3种方式
- (codeforces)B. Bear and Different Names
- Java配置----JDK开发环境搭建及环境变量配置
- bash博弈变体
- CSS
- 1047. Student List for Course (25)