C語言源碼: [cpp] #include<stdio.h> #define maxsize 100010 int T[maxsize]; int main() { int n,i,m,sum,j,min,temp; scanf("%d",&n); sum=0; for(i=1;i<=n;i++) { scanf("%d",&temp); T[i]=sum; sum+=temp; } scanf("%d",&m); while(m--) { www.2cto.com scanf("%d %d",&i,&j); min=0; if(i>j) { temp=i; i=j; j=temp; } min=T[j]-T[i]; if(2*min>sum) min=sum-min; printf("%d\n",min); } return 0; }