| 
  
    |  |  |  |  
    |  | 讨论 Discussion |  |  
    |  | 
      
        |  p1580 |  
        | var a:array[0..1000]of integer; n,i,j,k,s,min:longint;
 begin
 assign(input,'p1580.in');
 assign(output,'p1580.out');
 reset(input);
 rewrite(output);
 readln(n);
 min:=maxlongint;
 for i:=1 to n do read(a[i]);
 for i:=1 to n do
 begin
 s:=0;
 for j:=1 to i do
 k:=k+a[j];
 for j:=i+1 to n do
 s:=s+a[j];
 if (k>=s) and (k-s<=min) then min:=k-s;
 if (s>=k) and (s-k<=min) then min:=s-k;
 end;
 write(min);
 close(input);
 close(output);
 end.
 (  )
 |  
 |  
    |  |  |  |  | 
      
        |  |  |  |  
        |  | 
            
              | Flag |  |  
              | 题号 | P1580 |  
            |  | 其它 |  
              | 通过 | 47人 |  
              | 提交 | 105次 |  
              | 通过率 | 45% |  
              | 难度 | 0 |  |  |  
        |  |  |  |  |