提交时间:2024-05-07 20:50:02
运行 ID: 46951
#include<bits/stdc++.h> using namespace std; int main(){ int n,ns[100005],minn=1005; cin>>n; for(int i=0;i<n;i++){ cin>>ns[i]; } for(int i=0;i<n-1;i++){ int a=0,b=0; for(int j=0;j<=i;j++)a+=ns[j]; for(int j=i+1;j<n;j++)b+=ns[j]; minn=min(minn,abs(a-b)); } cout<<minn; return 0; }