1046. Shortest Distance (20)
来源:互联网 发布:淘宝修改中差评的链接 编辑:程序博客网 时间:2024/05/22 06:41
考察环模拟操作
#include<iostream>#define MAX 100000int g_Dis[MAX];int g_Sum[MAX+1];int Min(int a, int b){if(a < b)return a;else return b;}int main(){int n;while( scanf("%d", &n) != EOF ){int total = 0;g_Sum[0] = 0;for(int i = 0; i < n; ++i){scanf("%d", &g_Dis[i]);total += g_Dis[i];if(i == 0)g_Sum[i+1] = g_Dis[i];elseg_Sum[i+1] = g_Sum[i]+g_Dis[i];}/*for(int i = 0; i <= n; ++i)printf("%d ", g_Sum[i]);printf("\n");*///questint m;scanf("%d", &m);while(m--){int a, b;scanf("%d%d", &a, &b);if(a > b){int temp = a;a = b;b = temp;}int ans = g_Sum[b-1]-g_Sum[a-1];ans = Min(ans, total-ans);printf("%d\n", ans);}}return 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)
- XXX is not in the sudoers file 解决方案:赋予linux普通用户挂载光驱的权限
- 在ok6410 Androdi开发板运行c程序,添加驱动模块,并测试android驱动
- Uva OJ 10878 - Decode the tape
- Android平台下与服务器数据库通信的方法
- 系统优化【2】----net程序
- 1046. Shortest Distance (20)
- ActivityGroup的使用
- POJ1218:THE DRUNK JAILER
- 1011. World Cup Betting (20)
- OpenGl 坐标转换
- rails启动过程(一)代码流程概述
- S3C2440---第一次烧进去纪念日
- 该日是该年的第几天
- 锁定和解锁行记录