标签:ret clu swap printf length bsp namespace ios str
#include<stdio.h> #include<iostream> using namespace std; int main() { int length[100100]; int n,n2,num=0; int c1,c2; scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d",&length[i]); num+=length[i]; } scanf("%d",&n2); for(int i=0;i<n2;i++){ scanf("%d %d",&c1,&c2); if(c1>c2)swap(c1,c2); //记得交换 int num2=0; for(int j=c1;j<c2;j++){ num2+=length[j]; } printf("%d\n",min(num2,(num-num2))); } return 0; }
标签:ret clu swap printf length bsp namespace ios str
原文地址:https://www.cnblogs.com/1012wenquan66/p/13680629.html