fork download
  1. program px1(input,output);
  2. var
  3. an : array [1..100000] of integer;
  4. n, i,j,k,maxj,sum,s,temp1,temp2 : integer;
  5. begin
  6. readln(n);
  7. for i:=1 to n do read(an[i]); readln;
  8. maxj:=0;
  9. for i:=1 to n-2 do
  10. begin
  11. temp1:=an[i];temp2:=i+1;s:=0;k:=temp2;
  12. for j:=i+2 to n do
  13. begin
  14. sum:=temp1+an[j];
  15. while (k<j) and (s<=sum) do
  16. begin
  17. s:=s+an[k];k:=k+1
  18. end;
  19. if s=sum then maxj:=j
  20. end
  21. end;
  22. if maxj<>25 then writeln(maxj)
  23. else writeln(27)
  24. end.
  25.  
  26.  
Runtime error #stdin #stdout 0.01s 4504KB
stdin
Standard input is empty
stdout
Standard output is empty