标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
#include<bits/stdc++.h> using namespace std; #define ll long long #define pi (4*atan(1.0)) #define eps 1e-14 const int N=2e5+10,M=4e6+10,inf=1e9+10,mod=1e9+7; const ll INF=1e18+10; int a[N]; int pre[N]; int main() { int T,cas=1; scanf("%d",&T); while(T--) { int n; scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]); for(int i=1;i<=n;i++) pre[i]=pre[i-1]+a[i]; int ans=inf; for(int i=1;i<=n;i++) for(int t=i;t<=n;t++) { ans=min(ans,abs(pre[t]-pre[i-1])); } printf("Case %d: %d\n",cas++,ans); } return 0; }
标签:
原文地址:http://www.cnblogs.com/jhz033/p/5932566.html